# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
135913 | 2019-07-24T13:29:36 Z | model_code | Who wants to live forever? (CERC12_B) | C++17 | 583 ms | 1076 KB |
// CERC 2012 // Problem B: Who wants to live forever? // O(n) solution // Author: Arkadiusz Pawlik #include <iostream> #include <string> #include <algorithm> using namespace std; bool die(string s) { s += "0"; int n = s.size(); int l = ((n ^ (n-1)) + 1) / 2; int cnt = n / l; for (int i = 1; i < cnt; ++i) { for (int k = 0; k < l-1; ++k) { if (s[i*l+k] != s[i*l-2-k]) return false; } if (s[i*l-1] != '0') return false; } return true; } string ft(string s) { for (int i = 0; i < s.size(); ++i) { if (i % 3 == 2) continue; s[i] = (s[i] == '1') ? '0' : '1'; } return s; } int main() { int n; cin >> n; while(n--) { string s; cin >> s; if (die(s)) cout << "DIES" << endl; else cout << "LIVES" << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 243 ms | 648 KB | Output is correct |
4 | Correct | 17 ms | 376 KB | Output is correct |
5 | Correct | 583 ms | 1076 KB | Output is correct |