Submission #339168

#TimeUsernameProblemLanguageResultExecution timeMemory
339168cheissmartFootball (info1cup20_football)C++14
66 / 100
40 ms1388 KiB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;

	int t;
	cin >> t;
	while(t--) {
		int n, k;
		cin >> n >> k;
		if(k == 1) {
			int sg = 0;
			for(int i = 0; i < n; i++) {
				int x;
				cin >> x;
				sg ^= x & 1;
			}
			if(sg) cout << 1;
			else cout << 0;
		} else if(n == 1) {
			int x;
			cin >> x;
			function<bool(int, int)> win = [&] (int x, int k) -> bool {
				if(x & 1) return 1;
				if(k == 1) return 0;
				x /= 2;
				k /= 2;
				return win(x, k);
			};	
			cout << win(x, k);	
		} else if(k == 2) {
			vi x(n);
			int sg = 0;
			for(int i = 0; i < n; i++) {
				cin >> x[i];
				sg ^= x[i] & 1;
			}
			if(sg) cout << 1;
			else {
				int tt = 0;
				for(int i = 0; i < n; i++)
					tt ^= (x[i] / 2) & 1;
				cout << tt;
			}
		}
	}
	cout << endl;

}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...