답안 #675515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
675515 2022-12-27T11:37:48 Z QwertyPi CATS (NOI14_cats) C++14
0 / 25
288 ms 6052 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 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();
		}
	}
}

int32_t main(){
	int q; cin >> q;
	for(int i = 0; i < q; i++){
		int x, l, n; cin >> x >> l >> n;
		x--;
		int Ba = (l / (n * 2) + 1) * n * 2;
		if(l % (n * 2) > n || l < n){
			if(x % 4 == 1 || x % 4 == 2) Ba ^= 1;
		}else{
			if(x % 4 == 1 || x % 4 == 2) Ba ^= 1;
			if(x & 4) Ba ^= 1;
		}
		cout << Ba << endl;
	}
	
}

Compilation message

cats.cpp: In function 'long long int solve(long long int, long long int, long long int)':
cats.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
   35 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 288 ms 6052 KB Output isn't correct
2 Halted 0 ms 0 KB -