Submission #14673

#TimeUsernameProblemLanguageResultExecution timeMemory
14673nosiarCATS (NOI14_cats)C++14
4 / 25
1500 ms5728 KiB
#include <iostream> #include <cstring> #include <string> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <functional> #include <numeric> #include <limits> using namespace std; int x, l, n; int simulate(int x, int l, int n) { vector<int> s1(1000); vector<int> s2(1000); while (x) { if (s1.size() == 1) { int x = s1.back(); for (int i = 0; i < 100; ++i) s1.push_back(x); } if (s2.size() == 1) { int x = s2.back(); for (int i = 0; i < 100; ++i) s2.push_back(x); } s2.push_back(s1.back()); s1.pop_back(); for (int& i : s1) i ^= 1; if (s2.back() > l) { x--; if (x == 0) return s2.back(); } else { s2.back() += 2*n; s1.push_back(s2.back()); s1.push_back(s2.back()); s2.pop_back(); s2.pop_back(); } } } int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif int tests; cin >> tests; while (tests--) { cin >> x >> l >> n; /*int k = l / (2 * n) + 1; int z; if (x == 1) z = 0; else if (x % 4 == 0) z = 0; else z = 1; cout << 2 * k*n + z << endl;*/ cout << simulate(x, l, n) << endl; }}
#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...