Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

204MS 快速高效 优美易读 的 DFS ORZ WZC

Posted by wccy at 2012-08-10 20:17:52 on Problem 1198
In Reply To:双向dfs无压力 219MS AC!! Posted by:wzc1995 at 2012-08-10 19:26:38
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
struct _________
{int ____,_____;};
struct __________
{_________ _[5];}___________________,____________________; 
map<int , bool> _____________;
bool ___________[10][10];
int ________________[] = {-1, 1, 0, 0};
int _________________[] = { 0, 0, 1,-1};
inline bool ______________(const _________ &_______ ,const _________ &________)
{
	if(_______.____ != ________.____)
		return _______.____ < ________.____;
	return _______._____ < ________._____;
}
inline bool _______________(int ____, int _____)
{
	if(____ >= 1 && _____ >= 1 && ____ <= 8 && _____ <= 8)
		return true;
	return false;
}
inline bool _______________________(const __________ &____________)
{
	__________ ___________________ = ____________;
	sort(___________________._+1,___________________._+5,______________);
	int _____________________ = 1,__________________________(0);
	for(int ___ = 1; ___ <= 4; ___++)
	{
		__________________________ += ___________________._[___].____*_____________________;
		_____________________ *= 10;
		__________________________ += ___________________._[___]._____*_____________________;
		_____________________ *= 10;
	}
	return _____________[__________________________];
}
inline void ________________________(const __________ &____________)
{
	__________ ___________________ = ____________;
	sort(___________________._+1,___________________._+5,______________);
	int _____________________ = 1,__________________________(0);
	for(int ___ = 1; ___ <= 4; ___++)
	{
		__________________________ += ___________________._[___].____*_____________________;
		_____________________ *= 10;
		__________________________ += ___________________._[___]._____*_____________________;
		_____________________ *= 10;
	}
	_____________[__________________________] = true;
}
inline void __________________(const __________ &_______,int ______________________)
{
	________________________(_______);
	if(______________________ == 4) return;
	memset(___________,0,sizeof ___________);
	for(int ___ = 1; ___ <= 4; ___++)
		___________[_______._[___].____][_______._[___]._____] = true;
	for(int ___ = 1; ___ <= 4; ___++)
		for(int ______ = 0; ______ < 4; ______++)
		if(_______________(_______._[___].____+________________[______],_______._[___]._____+_________________[______]))
		{
			if(___________[_______._[___].____+________________[______]][_______._[___]._____+_________________[______]])
			{
				if(_______________(_______._[___].____ + 2*________________[______],_______._[___]._____ + 2*_________________[______])&&___________[_______._[___].____ + 2*________________[______]][_______._[___]._____ + 2*_________________[______]]==0)
				{
					__________ __ = _______;
					__._[___].____ = _______._[___].____ + 2*________________[______];
					__._[___]._____ = _______._[___]._____ + 2*_________________[______];
					__________________(__,______________________+1);
				}
			}
			else
			{
				__________ __ = _______;
				__._[___].____ = _______._[___].____ + ________________[______];
				__._[___]._____ = _______._[___]._____ + _________________[______];
				__________________(__,______________________+1);
			}
		}
}
inline bool _________________________(const __________ &_______,int ______________________)
{
	
	if(_______________________(_______))
		return true;
	if(______________________ == 4) return false;
	memset(___________,0,sizeof ___________);
	for(int ___ = 1; ___ <= 4; ___++)
		___________[_______._[___].____][_______._[___]._____] = true;
	for(int ___ = 1; ___ <= 4; ___++)
		for(int ______ = 0; ______ < 4; ______++)
		if(_______________(_______._[___].____+________________[______],_______._[___]._____+_________________[______]))
		{
			if(___________[_______._[___].____+________________[______]][_______._[___]._____+_________________[______]])
			{
				if(_______________(_______._[___].____ + 2*________________[______],_______._[___]._____ + 2*_________________[______])&&___________[_______._[___].____ + 2*________________[______]][_______._[___]._____ + 2*_________________[______]]==0)
				{
					__________ __ = _______;
					__._[___].____ = _______._[___].____ + 2*________________[______];
					__._[___]._____ = _______._[___]._____ + 2*_________________[______];
					if(_________________________(__,______________________+1))
						return true;
				}
			}
			else
			{
				__________ __ = _______;
				__._[___].____ = _______._[___].____ + ________________[______];
				__._[___]._____ = _______._[___]._____ + _________________[______];
				if(_________________________(__,______________________+1))
					return true;
			}
		}
	return false;
}
int main()
{
	while(~scanf("%d%d",&___________________._[1].____,&___________________._[1]._____))
	{
		_____________.clear();
		for(int ___ = 2; ___ <= 4; ___++)
			scanf("%d%d",&___________________._[___].____,&___________________._[___]._____);
		for(int ___ = 1; ___ <= 4; ___++)
			scanf("%d%d",&____________________._[___].____,&____________________._[___]._____);	
		__________________(___________________,0);
		if(_________________________(____________________,0)) puts("YES");
		else puts("NO");
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator