# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138479 | 2019-07-30T05:14:10 Z | 김세빈(#3318) | Who wants to live forever? (CERC12_B) | C++14 | 2 ms | 376 KB |
#include <bits/stdc++.h> using namespace std; bool simulate(string &S) { if(!(S.size() & S.size() - 1)) return true; string T; int i, s, ret = 0; for(i=0; i<S.size(); i++){ s = 0; if(i && S[i - 1] == '1') s ++; if(i + 1 < S.size() && S[i + 1] == '1') s ++; T.push_back("01"[s & 1]); if(s & 1) ret = 1; } swap(S, T); return ret; } bool tc(string S) { int i; for(i=0; i<20; i++){ if(!simulate(S)) return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); string S; int t; cin >> t; for(; t--; ){ cin >> S; cout << (tc(S)? "DIES" : "LIVES") << "\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |