QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390029#1827. Token Gameblack_moonrise#AC ✓167ms4160kbC++141.2kb2024-04-15 00:23:302024-04-15 00:23:30

Judging History

你现在查看的是最新测评结果

  • [2024-04-15 00:23:30]
  • 评测
  • 测评结果:AC
  • 用时:167ms
  • 内存:4160kb
  • [2024-04-15 00:23:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 311;
int Q;
int n = 300;
int sg[MAXN][MAXN];
bool hs[MAXN*2];
int query(int a, int b, int c, int d) {
	int f1 = abs(a-c) > 1;
	int f2 = abs(b-d) > 1;
	if (f1 && f2) {
		return sg[a][c] ^ sg[b][d];
	} else {
		int dis = abs(a-c) + abs(b-d);
		return dis>1;
	}
}
int main() {
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			if (abs(i-j)<=1) {
				sg[i][j] = 0;
			} else {
				memset(hs, 0, sizeof(hs));
				for (int t=1; t<i; t++) {
					hs[sg[t][j]] = true;
				}
				for (int t=1; t<j; t++) {
					hs[sg[i][t]] = true;
				}
				while (hs[sg[i][j]]) sg[i][j]++;
			}
		}
	}
	scanf("%d", &Q);
	int a[2][2], b[2][2];
	while (Q--) {
		for(int i=0; i<2; i++) for(int j=0; j<2; j++) scanf("%d", a[i]+j);
		int ans = 0;
		for(int p=0; p<2; p++) for(int q=0; q<2; q++) {
			for(int i=0; i<2; i++) for(int j=0; j<2; j++) b[i][j] = a[i][j];
			for(b[p][q]=1; b[p][q] < a[p][q]; b[p][q]++) {
				if(b[p][q^1] == b[p^1][q^1] && a[p][q] >= a[p^1][q] && b[p][q] <= a[p^1][q]) continue;
				ans += (query(b[0][0], b[0][1], b[1][0], b[1][1]) == 0);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 12ms
memory: 4156kb

input:

5
6 6 6 3
6 6 2 2
1 6 3 1
3 6 1 3
6 3 1 5

output:

3
0
1
1
0

result:

ok 5 number(s): "3 0 1 1 0"

Test #2:

score: 0
Accepted
time: 167ms
memory: 4160kb

input:

100000
215 233 28 258
15 243 61 148
172 28 96 37
15 132 62 27
41 186 255 54
145 192 249 263
274 70 185 197
50 101 202 230
256 11 285 19
149 268 163 107
177 201 216 126
65 17 105 263
143 148 2 230
40 128 259 176
183 192 293 169
281 59 240 229
257 157 126 182
161 51 164 14
149 191 227 102
55 14 267 19...

output:

3
1
1
1
1
2
2
3
1
1
3
1
1
1
1
3
3
1
1
1
1
1
1
2
1
1
1
2
1
1
3
1
3
1
1
2
1
1
1
3
4
1
1
3
1
2
2
1
1
1
3
1
1
1
3
1
1
1
1
2
3
1
3
1
1
3
1
3
3
2
1
2
3
3
1
1
1
2
2
1
2
1
3
1
1
1
1
1
2
1
4
1
1
1
3
3
1
1
1
1
2
1
1
1
1
3
2
3
2
1
1
3
1
1
1
1
2
1
1
2
3
1
3
1
1
1
2
3
3
1
2
3
1
1
1
1
1
2
3
2
2
2
1
1
3
1
1
1
2
2
...

result:

ok 100000 numbers