Submission #675496

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

using namespace std;

vector<int> S1, S2;

void out(){
	cout << "*****************" << endl;
	cout << "S1: "; for(auto i : S1) cout << i << ' '; 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();
	for(int i = 0; i < X; i++) S1.push_back(0);
	for(int i = 0; i < X; i++) S2.push_back(0);
	while(COUNTER){
		S2.push_back(S1.back()); S1.pop_back();
		for(auto& i : S1) i ^= 1;
		if(S2.back() > L){
			COUNTER--;
			if(COUNTER == 0) return S2.back();
		}else{
			S2.back() += N * 2;
			S1.push_back(S2.back());
			S1.push_back(S2.back());
			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:32:1: warning: control reaches end of non-void function [-Wreturn-type]
   32 | }
      | ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1593 ms 9024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1586 ms 8896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1594 ms 2240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1590 ms 2504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 281 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 279 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -