# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675528 | 2022-12-27T12:03:34 Z | QwertyPi | CATS (NOI14_cats) | C++14 | 312 ms | 8016 KB |
#include <bits/stdc++.h> #define int long long using namespace std; deque<int> S1, S2; bool fl; void out(){ cout << "*****************" << endl; cout << "S1: "; for(auto i : S1) cout << (i ^ fl) << ' '; cout << endl; cout << "S2: "; for(auto i : S2) cout << i << ' '; cout << endl; } int f(int X, int L, int N){ int COUNTER = X; S1.clear(); S2.clear(); fl = false; while(COUNTER){ // out(); if(S1.empty()) S1.push_front(0); S2.push_back(S1.back() ^ fl); S1.pop_back(); fl ^= 1; if(S2.back() > L){ COUNTER--; if(COUNTER == 0) return S2.back(); }else{ if(S2.size() == 1) S2.push_front(0); S2.back() += N * 2; S1.push_back(S2.back() ^ fl); S1.push_back(S2.back() ^ fl); S2.pop_back(); S2.pop_back(); } } } int g(int x, int l, int n){ x--; int Ba = (l / (n * 2) + 1) * n * 2; if(x % 4 == 1 || x % 4 == 2) Ba ^= 1; int d = l / (n * 2); for(int b = 2; b <= min(60LL, d + 1); b++){ if(x & (1LL << b)) Ba ^= 1; } return Ba; } int32_t main(){ int q; cin >> q; for(int i = 0; i < q; i++){ int x, l, n; cin >> x >> l >> n; cout << g(x, l, n) << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 212 KB | Output is correct |
2 | Correct | 2 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 212 KB | Output is correct |
2 | Correct | 3 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 344 KB | Output is correct |
2 | Correct | 27 ms | 692 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 292 ms | 2084 KB | Output is correct |
2 | Correct | 312 ms | 8016 KB | Output is correct |