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

Re:哪位牛人帮忙看一下1753为啥WA???

Posted by harrymwz at 2009-08-19 22:23:12
In Reply To:哪位牛人帮忙看一下1753为啥WA??? Posted by:harrymwz at 2009-08-19 20:15:24
> #include<iostream>
> #include<bitset>
> using namespace std;
> unsigned long id[32768];
> bool ivsit[32678];
> char map[4][4];
> int cnt=0;
> int main(){
>     memset(id,0,sizeof id/sizeof(id[0]));
>     memset(ivsit,false,sizeof ivsit/sizeof(ivsit[0]));
>    int front=0,rear=1;
>    bitset<16> bits;
>    bits.reset();
>    for(int i=0;i<4;++i){
>       for(int j=0;j<4;++j){
>            cin>>map[i][j];      
>       }        
>    } 
>    for(int i=0;i<4;++i){
>       for(int j=0;j<4;++j){
>            if(map[i][j]=='w')
>               bits.set(4*i+j+1);     
>       }        
>    } 
>    if(bits.to_ulong()==65535||bits.to_ulong()==0) {
>       cout<<"0"<<endl;
>       return 0;
>    }
>    else{
>        id[front]=bits.to_ulong();  
>        ivsit[id[front]]=true;
>        while(front<rear){
>           for(int i=2;i<18;++i){
>               if(bits.flip(i-1).to_ulong()==65535||bits.flip(i-1).to_ulong()==0){
>                   ++cnt; cout<<cnt<<endl ;return 0;
>               }   
>               else{
>                    if(!ivsit[bits.to_ulong()])
>                        id[rear++]=bits.to_ulong();
>                    ivsit[bits.to_ulong()]=true;
>               }    
>               if(bits.flip(i-1).flip(i+1).to_ulong()==65535||bits.flip(i-1).flip(i+1).to_ulong()==0){
>                   ++cnt;cout<<cnt<<endl; return 0; 
>               }   
>               else{
>                    if(!ivsit[bits.to_ulong()])
>                        id[rear++]=bits.to_ulong();
>                    ivsit[bits.to_ulong()]=true;
>               }    
>               if(bits.flip(i+1).flip(i+4).to_ulong()==65535||bits.flip(i+1).flip(i+4).to_ulong()==0){
>                   ++cnt;cout<<cnt<<endl; return 0;              }   
>               else{
>                    if(!ivsit[bits.to_ulong()])
>                        id[rear++]=bits.to_ulong();
>                    ivsit[bits.to_ulong()]=true;
>               }    
>               if(bits.flip(i+4).flip(i-4).to_ulong()==65535||bits.flip(i+4).flip(i-4).to_ulong()==0){
>                   ++cnt; cout<<cnt<<endl; return 0; 
>               }   
>               else{
>                    if(!ivsit[bits.to_ulong()])
>                        id[rear++]=bits.to_ulong();
>                    ivsit[bits.to_ulong()]=true;
>               }    
>               front++;          
>           }  
>             
>            ++cnt;              
>        }  
>        
>        
>    }  
>   cout<<"Impossible"<<endl;
>   system("pause"); 
>        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