Submission #675504

# Submission time Handle Problem Language Result Execution time Memory
675504 2022-12-27T11:19:33 Z QwertyPi CATS (NOI14_cats) C++14
8 / 25
1500 ms 262144 KB
#include <bits/stdc++.h>

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 solve(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 main(){
	int q; cin >> q;
	for(int i = 0; i < q; i++){
		int x, l, n; cin >> x >> l >> n;
		cout << solve(x, l, n) << endl;
	} 
}

Compilation message

cats.cpp: In function 'int solve(int, int, int)':
cats.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 15 ms 340 KB Output is correct
2 Correct 15 ms 1948 KB Output is correct
3 Correct 12 ms 868 KB Output is correct
4 Correct 9 ms 724 KB Output is correct
5 Correct 11 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 610 ms 2160 KB Output is correct
2 Correct 391 ms 2428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1577 ms 1920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1579 ms 1332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1128 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1145 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -