| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:坑爹啊!!不是搜索吗?why wa。。In Reply To:坑爹啊!!不是搜索吗?why wa。。 Posted by:zz_1215 at 2012-05-10 22:03:44 我也是WA死了==
> #include<iostream>
> #include<vector>
> #include<algorithm>
> #include<cstdio>
> #include<queue>
> #include<stack>
> #include<string>
> #include<map>
> #include<set>
> #include<cmath>
> #include<cassert>
> #include<cstring>
> #include<iomanip>
> using namespace std;
>
> #define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++)
> #define FF(i,a) for( int i = 0 ; i < (a) ; i ++)
> #define FFD(i,a) for( int i = (a)-1 ; i >= 0 ; i --)
> #define S64(a) scanf(in64,&a)
> #define SS(a) scanf("%d",&a)
> #define LL(a) ((a)<<1)
> #define RR(a) (((a)<<1)+1)
> #define pb push_back
> #define CL(Q) while(!Q.empty())Q.pop()
> #define MM(name,what) memset(name,what,sizeof(name))
> #define read freopen("in.txt","r",stdin)
> #define write freopen("out.txt","w",stdout)
>
> const int inf = 0x3f3f3f3f;
> const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
> const double oo = 10e9;
> const double eps = 1e-10;
> const double pi = acos(-1.0);
>
> char a[6][6];
> string s;
> int sx,sy;
>
> int num(int x,int y)
> {
> return (x-1)*4+y;
> }
>
> bool you(int x,int temp)
> {
> return (x&(1<<temp));
> }
>
> bool win(int x)
> {
> int temp;
> bool ok;
> for(int u=1;u<=4;u++)
> {
> ok = true;
> for(int k=1;k<=4;k++)
> {
> temp = num(u,k);
> if(!you(x,temp))
> {
> ok = false;
> break;
> }
> }
> if(ok) return true;
> }
>
> for(int k=1;k<=4;k++)
> {
> ok = true;
> for(int u=1;u<=4;u++)
> {
> temp = num(u,k);
> if(!you(x,temp))
> {
> ok = false;
> break;
> }
> }
> if(ok) return true;
> }
> ok = true;
> for(int u=1;u<=4;u++)
> {
> temp = num(u,u);
> if(!you(x,temp))
> {
> ok = false;
> break;
> }
> }
> if(ok) return true;
>
> ok = true;
> for(int u=1;u<=4;u++)
> {
> temp = num(5-u,u);
> if(!you(x,temp))
> {
> ok = false;
> break;
> }
> }
> if(ok) return true;
>
> return false;
> }
>
> bool dfwin(int step,int x,int y)
> {
> if(win(x)) return true;
> if(win(y)) return false;
> if(step == 17) return false;
>
> if(step%2)
> {
> for(int u=1;u<=16;u++)
> {
> if(!you(x,u) && !you(y,u))
> {
> if(dfwin(step+1,x+(1<<u),y))
> {
> return true;
> }
> }
> }
> return false;
> }
> else
> {
> for(int u=1;u<=16;u++)
> {
> if(!you(x,u) && !you(y,u))
> {
> if(!dfwin(step+1,x,y+(1<<u)))
> {
> return false;
> }
> }
> }
> return true;
> }
> }
>
> bool dflose(int step,int x,int y)
> {
> if(win(x)) return false;
> if(win(y)) return true;
> if(step == 17) return false;
>
> if(step%2)
> {
> for(int u=1;u<=16;u++)
> {
> if(!you(x,u) && !you(y,u))
> {
> if(dflose(step+1,x+(1<<u),y))
> {
> return true;
> }
> }
> }
> return false;
> }
> else
> {
> for(int u=1;u<=16;u++)
> {
> if(!you(x,u)&&!you(y,u))
> {
> if(!dflose(step+1,x,y+(1<<u)))
> {
> return false;
> }
> }
> }
> return true;
> }
> }
>
> bool cap(int step,int x,int y)
> {
> if(win(x) || win(y)) return false;
> if(step == 17) return true;
> if(step%2)
> {
> for(int u=1;u<=16;u++)
> {
> if(!you(x,u) && !you(y,u))
> {
> if(cap(step+1,x+(1<<u),y))
> {
> return true;
> }
> }
> }
> return false;
> }
> else
> {
> for(int u=1;u<=16;u++)
> {
> if(!you(x,u) && !you(y,u))
> {
> if(!cap(step+1,x,y+(1<<u)))
> {
> return false;
> }
> }
> }
> return true;
> }
> }
>
> bool start()
> {
> int temp;
> int x,y;
> x = 0;
> y = 0;
> for(int u=1;u<=4;u++)
> {
> for(int k=1;k<=4;k++)
> {
> if(a[u][k]=='x')
> {
> temp = num(u,k);
> x |= 1<<temp;
> }
> else if(a[u][k] == 'o')
> {
> temp = num(u,k);
> y |= 1<<temp;
> }
> }
> }
>
> int step = sx+sy+1;
>
> if(s=="LOSE")
> {
> return dflose(step,x,y);
> }
> else if(s=="WIN")
> {
> return dfwin(step,x,y);
> }
> else if(s=="TIE")
> {
> return cap(step,x,y);
> }
> }
>
> int main()
> {
> int T;
> cin>>T;
> while(T--)
> {
> cin>>s;
> sx =0;
> sy= 0;
> for(int i=1;i<=4;i++)
> {
> for(int j=1;j<=4;j++)
> {
> cin>>a[i][j];
> if(a[i][j]=='x')
> {
> sx++;
> }
> else if(a[i][j]=='o')
> {
> sy++;
> }
> }
> }
> if(start())
> {
> cout<<"YES"<<endl;
> }
> else
> {
> cout<<"NO"<<endl;
> }
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator