Submission #15355

# Submission time Handle Problem Language Result Execution time Memory
15355 2015-07-12T06:37:36 Z myungwoo 로봇 심판의 님 게임 (kriii3_F) C++14
0 / 79
251 ms 5616 KB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
typedef long long lld;

int N, M, K;
lld A[21], G[21];
vector <lld> P, Q;
vector <int> C;

inline lld invalid(lld n)
{
	return C[n];
}

inline lld get_grundy(lld n)
{
	if (!n) return 0;
	lld me = invalid(n), you = invalid(n-1);
	return me > you ? 0 : (n - me);
}

int main()
{
	scanf("%d%d%d", &N, &M, &K);
	for (int i=0;i<N;i++){
		lld x; scanf("%lld", &x); P.pb(x);
	}
	for (int i=0;i<M;i++){
		lld x; scanf("%lld", &x); Q.pb(x);
	}
	int V = 0;
	for (int i=1;i<=K;i++){
		scanf("%lld", A+i);
		V = max(V, (int)A[i]);
	}
	C.resize(V+1, 0);
	for (int i=1;i<=V;i++){
		C[i] = C[i-1];
		bool sw = 0;
		for (int j=0;j<N;j++){
			if (i % P[j] == 0) sw = 1;
		}
		bool sw2 = 1;
		for (int j=0;j<M;j++){
			if (i % Q[j] == 0) sw2 = 0;
		}
		if (sw && sw2) C[i]++;
	}
	lld x = 0;
	for (int i=1;i<=K;i++){
		G[i] = get_grundy(A[i]);
		x ^= G[i];
	}
	for (int i=1;i<=K;i++){
		if (!G[i]){ puts("0 0"); continue; }
		lld ox = x ^ G[i];
		lld p = 0, q = 0;
		for (int j=0;j<A[i];j++) if (get_grundy(j) == ox) p++, q = A[i] - j;
		printf("%lld %lld\n", p, q);
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 251 ms 5616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -