Submission #339163

#TimeUsernameProblemLanguageResultExecution timeMemory
339163cheissmartFootball (info1cup20_football)C++14
26 / 100
2073 ms2540 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, sg = 0;
		cin >> n >> k;
		if(k == 1) {
			for(int i = 0; i < n; i++) {
				int x;
				cin >> x;
				x %= (k + 1);
				sg ^= x;
			}
			if(sg > 0) cout << 1;
			else cout << 0;
		} else if(n == 1) {
			int x;
			cin >> x;
			bool dp[102][102][102] = {};
			for(int i = 1; i <= x; i++) {
				for(int a = 1; a <= k; a++) {
					for(int b = 1; b <= k; b++) {
						for(int take = 1; take <= a && take <= x; take++)
							if(dp[x - take][b][take] == 0) {
								dp[i][a][b] = 1;
								break;
							}
					}
				}
			}
			cout << dp[x][k][k];
		}
	}
	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...