Submission #1143349

#TimeUsernameProblemLanguageResultExecution timeMemory
1143349Stormtrooper007Walk (POI13_spa)C++20
12 / 100
206 ms3880 KiB
#include <bits/stdc++.h> using namespace std; bitset<5000000>used; int main() { ios_base::sync_with_stdio(false); cin.tie(); cout.tie(); int n,m; cin>>n>>m; string s; string f; int st=0,fn=0; cin>>s>>f; int p=0; for(int i=n-1;i>=0;i--) { if(s[i]=='1') { st+=(1<<p); } p++; } p=0; for(int i=n-1;i>=0;i--) { if(f[i]=='1') { fn+=(1<<p); } p++; } for(int i=0;i<m;i++) { string str; cin>>str; int aux=0; p=0; for(int j=n-1;j>=0;j--) { if(str[j]=='1') { aux+=(1<<p); } p++; } //cout<<aux<<"na\n"; used[aux]=1; } if(st==fn) { cout<<"TAK"; return 0; } queue<int>q; used[st]=1; q.push(st); while(!q.empty()) { int nr=q.front(); q.pop(); p=0; int aux=nr; for(int j=n-1;j>=0;j--) { if(!(nr&(1<<p))) { aux+=(1<<p); } else { aux-=(1<<p); } if(!used[aux]) { used[aux]=1; q.push(aux); } if(!(nr&(1<<p))) aux-=(1<<p); else aux+=(1<<p); p++; } // cout<<nr<<'\n'; } if(used[fn]==0) { cout<<"NIE"; } else { cout<<"TAK"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...