Submission #124637

#TimeUsernameProblemLanguageResultExecution timeMemory
124637johuthaCATS (NOI14_cats)C++14
8 / 25
1557 ms262148 KiB
#include <vector> #include <iostream> #define int int64_t using namespace std; struct solver { int x, l, n; vector<int> s1; vector<int> s2; void calc() { s1.resize(2, 0); s2.resize(2, 0); int ctr = 0; while (x > 0) { if (s1.size() == 0) {s1.push_back(0);} s2.push_back(s1.back() ^ ctr); s1.pop_back(); ctr += 1; ctr %= 2; if (s2.back() > l) { x--; if (x == 0) cout << s2.back() << "\n"; } else { if (s2.size() == 0) s2.push_back(0); s2.back() += 2*n; s1.push_back(s2.back() ^ ctr); s1.push_back(s2.back() ^ ctr); if (s2.size() != 0) s2.pop_back(); if (s2.size() != 0) s2.pop_back(); } } } }; signed main() { //ios_base::sync_with_stdio(0); //cin.tie(0); int q; cin >> q; for (int c = 0; c < q; c++) { solver s; cin >> s.x >> s.l >> s.n; s.calc(); } }
#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...