제출 #525170

#제출 시각아이디문제언어결과실행 시간메모리
525170maks007Football (info1cup20_football)C++14
34 / 100
2073 ms1388 KiB
#include <bits/stdc++.h>

using namespace std;
#define int long long
int32_t main(void) {
	int t;
	cin >> t;
	int countdown = 0;
	while(t --){
		int n, k;
		cin >> n >> k;
		vector <int> a(n);
		function <int()> check=[&]() {
			int cnt = 0;
			for(int i = 0; i < n; i++) {
				if(a[i] == 1 or a[i] == 0) cnt ++;
			}
			if(cnt == n) return 0;
			else return 1;
		};
		for(int i = 0; i < n; i ++) cin >> a[i];
		int sum = accumulate(a.begin(), a.end(), 0ll);
		if(sum % 2 == 1) {
			cout << 1;
			continue;
		}
		if(k == 1) {
			cout << 0;
			continue;
		}
		int move = 0;
		while(true){
			if(!check()) {
				cout << move;
				goto end;
			}
			move = 1 - move;
			for(int i = 0 ; i < n; i ++) {
				if(a[i] > 1) {
					a[i] --;
					a[i] --;
					break;
				}
			}
		}
		cout << 1-move;
		end:;
 		/*if(n == 1) {
			if(k >= a[0]) {
				cout << 1;
				continue;
			}
			if(a[0] % 2 == 1) {
				cout << 1;
				continue;
			}
			n = a[0];
			int mx = 1;
			while(n % 2 == 0) {
				n /= 2;
				mx *= 2;
			}
			if(k >= mx and n > 1) {
				cout << 1;
			}else cout << 0;	
			continue;
		}
		if(k == 1) {
			int sum = accumulate(a.begin(), a.end(), 0ll);
			if(sum % 2 == 1) {
				cout << 1;
			}else cout << 0;
			continue;
		}else if(*max_element(a.begin(), a.end()) <= 3) {
			int sum = 0;
			for(int i = 0; i < a.size(); i ++) {
				if(a[i] % 2 == 1) sum += 1;
			}
			int move = 0;
			for(int i = 0; i < a.size(); i ++) {
				move += (int)(a[i] / 2);
			}
			if(move % 2 == 0) {
				if(sum % 2 == 1) {
					cout << 1;
				}else cout << 0;
			}else {
				if(sum % 2 == 0) cout << 1;
				else cout << 0;
			}
		}else if(k == 2) {
			int sum = accumulate(a.begin(), a.end(), 0ll);
			if(sum % 2 == 1) {
				cout << 1;
				continue;
			}
			int even = 0, odd = 0;
			for(int i = 0; i < a.size(); i ++) {
				if(a[i] % 2 == 1) odd += a[i];
				else even += a[i];
			}
			
			continue;
		}	*/
	}
	return false;
} 

컴파일 시 표준 에러 (stderr) 메시지

football.cpp: In function 'int32_t main()':
football.cpp:8:6: warning: unused variable 'countdown' [-Wunused-variable]
    8 |  int countdown = 0;
      |      ^~~~~~~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…