Submission #32010

#TimeUsernameProblemLanguageResultExecution timeMemory
32010kdh9949Walk (POI13_spa)C++14
12 / 100
5000 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; ll s, e; unordered_set<ll> fb, ss; queue<ll> q; const int lim = 5000005; ll get(){ char buf[62]; scanf("%s", buf); ll ret = 0; for(int i = n - 1, j = 0; i >= 0; i--, j++){ ret += (buf[i] - '0') * (1LL << j); } return ret; } int main(){ scanf("%d%d", &n, &k); s = get(); e = get(); for(int i = 0; i < k; i++) fb.insert(get()); q.push(s); ss.insert(s); while(!q.empty() && ss.size() < lim){ ll cur = q.front(); q.pop(); for(int i = 0; i < n; i++){ ll t = cur ^ (1LL << i); if(ss.find(t) == ss.end() && fb.find(t) == fb.end()){ ss.insert(t); q.push(t); } } } if(ss.find(e) != ss.end()){ puts("TAK"); return 0; } if(ss.size() < lim){ puts("NIE"); return 0; } ss.clear(); queue<ll>().swap(q); q.push(e); ss.insert(e); while(!q.empty() && ss.size() < lim){ ll cur = q.front(); q.pop(); for(int i = 0; i < n; i++){ ll t = cur ^ (1LL << i); if(ss.find(t) == ss.end() && fb.find(t) == fb.end()){ ss.insert(t); q.push(t); } } } puts(ss.size() == lim ? "TAK" : "NIE"); }

Compilation message (stderr)

spa.cpp: In function 'll get()':
spa.cpp:12:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  char buf[62]; scanf("%s", buf);
                                ^
spa.cpp: In function 'int main()':
spa.cpp:21:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
                       ^
#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...