QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137285#2353. Maharajas are Going HomePlentyOfPenalty#WA 116ms21652kbC++201.5kb2023-08-10 09:34:132023-08-10 09:34:16

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 09:34:16]
  • 评测
  • 测评结果:WA
  • 用时:116ms
  • 内存:21652kb
  • [2023-08-10 09:34:13]
  • 提交

answer

#include "bits/stdc++.h"
const int MAXN = 2011;
typedef std::pair<int,int> pii;
std::bitset<MAXN>row[MAXN],col[MAXN],diag[MAXN<<1|1], tp;
int f[MAXN][MAXN];
void init()
{
	int n=2000;
	for(int i=1;i<=n;++i)row[i].set(),col[i].set();
	for(int i=1;i<=n*2;++i)diag[i].set();
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
		{
			tp=row[i]&col[j]&diag[i-j+n];
			if(i>1&&j>2)tp[f[i-1][j-2]]=0;
			if(i>2&&j>1)tp[f[i-2][j-1]]=0;
			int &cur=f[i][j];
			cur=tp._Find_first();
			row[i][cur]=0;
			col[j][cur]=0;
			diag[i-j+n][cur]=0;
		}
}
pii a[MAXN];
int bestx=MAXN,besty=MAXN;
void update(int x,int y)
{
	if(x<bestx)bestx=x,besty=y;
	else if(x==bestx&&y<besty)besty=y;
}
int main()
{
	std::ios::sync_with_stdio(0),std::cin.tie(0);
	init();
	 int task;
	 std::cin>>task;
	 while(task--)
	 {
		int k,res=0;
		std::cin>>k;
		for(int i=1;i<=k;++i)
		{
			std::cin>>a[i].first>>a[i].second;
			res^=f[a[i].first][a[i].second];
		}
		if(!res){puts("-1 -1 -1");continue;}
		bestx=MAXN,besty=MAXN;
		for(int w=1;w<=k;++w)
		{
			int x=a[w].first,y=a[w].second;
			int r=res^f[x][y];
			for(int j=1;j<y;++j)
				if(f[x][j]==r)update(x,j);
			
			for(int i=1;i<x;++i)
				if(f[i][y]==r)update(i,y);
			for(int k=1;x>k&&y>k;++k)
				if(f[x-k][y-k]==r)update(x-k,y-k);
			// printf("i=%d,x=%d,y=%d\n",w,bestx,besty);
			if(x>1&&y>2&&f[x-1][y-2]==r)update(x-1,y-2);
			if(x>2&&y>1&&f[x-2][y-1]==r)update(x-2,y-1);
			if(bestx<MAXN&&besty<MAXN)
			{
				printf("%d %d %d\n",w,bestx,besty);
				break;
			}
		}
	 }
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 111ms
memory: 21632kb

input:

3
5
2 3
3 2
3 3
3 3
3 3
1
2 4
2
1 1
3 2

output:

3 1 1
-1 -1 -1
2 1 1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 113ms
memory: 21452kb

input:

1
1
1 1

output:

-1 -1 -1

result:

ok single line: '-1 -1 -1'

Test #3:

score: 0
Accepted
time: 107ms
memory: 21472kb

input:

100
1
5 5
1
1 5
1
5 4
1
4 4
1
2 2
1
5 3
1
4 5
1
2 4
1
4 1
1
3 2
1
3 2
1
1 4
1
2 5
1
4 2
1
5 3
1
5 5
1
4 2
1
3 4
1
3 4
1
4 2
1
3 1
1
1 5
1
1 4
1
4 1
1
4 5
1
2 5
1
5 1
1
4 1
1
2 4
1
2 5
1
3 4
1
2 5
1
5 4
1
4 4
1
2 3
1
3 4
1
5 4
1
1 3
1
3 4
1
1 5
1
5 1
1
2 3
1
3 1
1
1 1
1
5 2
1
2 5
1
1 4
1
3 3
1
4 3
1
...

output:

1 1 1
1 1 1
1 2 4
1 1 1
1 1 1
1 4 2
1 2 4
-1 -1 -1
1 1 1
1 1 1
1 1 1
1 1 1
1 2 4
-1 -1 -1
1 4 2
1 1 1
-1 -1 -1
1 2 4
1 2 4
-1 -1 -1
1 1 1
1 1 1
1 1 1
1 1 1
1 2 4
1 2 4
1 1 1
1 1 1
-1 -1 -1
1 2 4
1 2 4
1 2 4
1 2 4
1 1 1
1 1 1
1 2 4
1 2 4
1 1 1
1 2 4
1 1 1
1 1 1
1 1 1
1 1 1
-1 -1 -1
1 4 2
1 2 4
1 1 1
...

result:

ok 100 lines

Test #4:

score: 0
Accepted
time: 115ms
memory: 21476kb

input:

100
1
10 10
1
9 8
1
2 5
1
9 10
1
3 6
1
1 2
1
1 2
1
10 6
1
6 4
1
10 8
1
7 1
1
1 3
1
4 2
1
2 1
1
1 5
1
10 4
1
6 7
1
7 2
1
7 1
1
10 2
1
4 1
1
9 3
1
9 8
1
2 2
1
2 3
1
1 9
1
3 3
1
3 9
1
9 4
1
2 2
1
6 8
1
1 3
1
3 10
1
7 6
1
10 10
1
7 8
1
2 7
1
5 3
1
8 6
1
4 4
1
9 5
1
5 1
1
2 1
1
4 1
1
3 1
1
1 9
1
5 7
1
9 ...

output:

1 1 1
1 6 5
1 2 4
1 5 6
1 2 4
1 1 1
1 1 1
1 5 6
1 2 4
1 4 2
1 1 1
1 1 1
-1 -1 -1
1 1 1
1 1 1
1 2 4
1 3 7
1 4 2
1 1 1
1 4 2
1 1 1
1 7 3
1 6 5
1 1 1
1 1 1
1 1 1
1 1 1
1 3 7
1 2 4
1 1 1
1 2 4
1 1 1
1 3 7
1 5 6
1 1 1
1 5 6
1 2 4
1 4 2
1 4 2
1 1 1
1 6 5
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 2 4
1 7 3
1 4 2
1 3...

result:

ok 100 lines

Test #5:

score: 0
Accepted
time: 106ms
memory: 21652kb

input:

100
2
100 100
87 49
2
38 68
61 81
2
41 26
82 40
2
15 92
26 90
2
87 50
76 15
2
41 85
57 30
2
52 7
73 19
2
78 15
95 71
2
51 72
5 34
2
20 83
74 1
2
63 42
74 75
2
97 96
35 72
2
17 84
98 52
2
84 37
50 5
2
55 26
62 4
2
67 13
45 64
2
11 93
45 58
2
39 9
64 26
2
49 17
40 18
2
38 51
34 2
2
30 6
50 60
2
19 24
...

output:

1 91 91
2 30 50
2 27 40
2 10 74
1 56 50
1 20 64
2 51 19
2 23 71
1 12 33
1 7 70
1 29 42
1 86 85
2 64 52
1 28 37
1 49 20
2 18 64
1 2 84
2 45 7
1 41 17
1 38 20
1 30 5
1 19 22
1 10 42
1 9 11
1 32 84
2 42 43
1 19 14
1 24 35
1 5 4
2 57 55
1 51 3
2 75 25
1 10 64
1 14 30
1 32 29
2 1 45
1 18 65
2 12 46
1 49 ...

result:

ok 100 lines

Test #6:

score: 0
Accepted
time: 115ms
memory: 21600kb

input:

100
3
200 200
131 95
32 174
3
90 177
120 177
83 162
3
139 197
56 14
151 88
3
168 34
1 13
179 181
3
119 15
123 165
132 113
3
80 198
150 34
183 118
3
15 185
187 103
6 15
3
193 42
99 155
88 9
3
1 20
19 118
130 121
3
167 54
37 116
27 84
3
8 163
136 50
96 43
3
194 145
58 50
162 188
3
169 181
192 43
167 2...

output:

1 15 15
2 20 77
1 75 133
1 166 34
2 9 51
1 19 198
1 15 47
1 126 42
3 22 121
1 52 54
1 8 29
1 60 11
1 98 110
1 88 19
3 13 112
1 29 91
1 14 4
1 4 84
1 11 58
1 55 109
2 114 112
1 10 117
2 52 15
1 4 23
1 17 75
1 39 2
1 4 185
1 64 47
1 13 145
1 66 33
1 16 55
1 137 53
1 32 9
1 146 11
3 120 69
2 48 46
3 9 ...

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 107ms
memory: 21424kb

input:

100
5
500 500
412 315
268 386
7 71
293 234
5
89 405
380 251
212 313
319 289
424 1
5
28 410
110 148
413 360
185 118
192 330
5
284 167
405 475
386 175
131 486
498 235
5
426 10
287 434
435 348
61 183
30 483
5
417 81
433 143
297 150
100 72
368 183
5
257 315
382 288
380 131
426 174
140 5
5
377 418
103 10...

output:

1 212 500
1 89 47
1 28 55
2 385 475
3 403 348
2 421 131
2 267 288
1 196 418
4 204 378
1 314 55
1 117 27
1 30 150
2 64 112
1 3 10
1 388 409
4 20 165
1 140 16
3 153 336
1 168 403
5 1 399
3 91 230
3 58 398
2 19 143
3 165 472
1 3 164
1 119 377
3 182 392
3 168 99
1 206 86
4 83 284
2 24 132
2 121 436
1 11...

result:

ok 100 lines

Test #8:

score: 0
Accepted
time: 115ms
memory: 21492kb

input:

100
8
1000 1000
131 762
404 493
235 438
648 787
905 559
178 650
236 286
8
218 483
744 690
589 895
77 2
577 355
453 405
780 760
11 198
8
862 323
144 834
503 51
908 62
814 794
213 894
455 113
323 512
8
435 880
684 150
109 541
756 458
814 763
635 375
136 601
294 735
8
427 907
16 155
36 166
796 522
99 7...

output:

2 131 176
2 676 690
5 629 609
4 13 458
2 16 111
1 73 860
1 168 327
2 875 48
5 151 141
8 128 822
1 165 363
1 402 990
3 122 716
3 174 342
2 126 217
1 544 217
7 171 338
2 58 781
5 451 163
7 30 285
1 582 686
1 340 204
2 85 447
3 40 40
1 344 646
1 24 375
1 260 217
4 338 621
1 196 384
1 384 669
1 237 439
...

result:

ok 100 lines

Test #9:

score: -100
Wrong Answer
time: 116ms
memory: 21388kb

input:

100
10
2000 2000
1616 1893
1722 1287
1284 1348
1288 280
989 762
159 632
9 218
1263 1931
667 473
10
984 519
597 1841
896 1752
1709 369
444 1128
1931 679
452 941
1117 464
1606 1177
1417 728
10
1366 1361
1980 1662
1105 403
1353 922
255 1399
613 1343
410 120
1908 1284
1801 468
1 66
10
1233 433
151 1728
...

output:

1 199 2000
2 191 1435
1 81 76
2 151 883
1 82 549
1 1296 480
2 397 373
1 115 632
1 211 997
1 13 1929
1 236 1082
1 200 1864
1 1426 1476
1 314 240
1 875 512
1 595 209
1 550 925
1 23 278
1 464 607
3 692 541
1 126 1350
1 256 681
2 421 429
1 265 627
1 200 700
1 198 912
1 507 263
2 1047 1573
1 731 1545
1 4...

result:

wrong answer 1st lines differ - expected: '1 1000 2000', found: '1 199 2000'