답안 #675494

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
675494 2022-12-27T10:56:10 Z QwertyPi CATS (NOI14_cats) C++14
0 / 25
1500 ms 2504 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();
	S1.push_back(0);
	while(COUNTER){
		S2.push_back(S1.empty() ? 0 : S1.back()); if(S1.size()) 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());
			if(S2.size()) S2.pop_back();
			if(S2.size()) 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:31:1: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 296 ms 2504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1571 ms 2424 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1589 ms 396 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1588 ms 968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1584 ms 1056 KB Time limit exceeded
2 Halted 0 ms 0 KB -