QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22493#2353. Maharajas are Going HomeDaBenZhongXiaSongKuaiDiAC ✓853ms28308kbC++202.8kb2022-03-09 19:09:282022-04-30 01:12:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 01:12:44]
  • 评测
  • 测评结果:AC
  • 用时:853ms
  • 内存:28308kb
  • [2022-03-09 19:09:28]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<bitset>
using namespace std;
inline int read()
{
	int n=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		n=n*10+ch-'0';
		ch=getchar();
	}
	return n*f;
}
bitset<6005>h[4005],l[4005],dj[4005],tmp;
int sg[2005][2005];
int tx[4005],ty[4005];
int main()
{
	int ans=0;
	for(int i=1;i<=4000;i++)
	{
		h[i].set();
		l[i].set();
		dj[i].set();
	}
	for(int i=1;i<=2000;i++)
	{
		for(int j=1;j<=2000;j++)
		{
			tmp.set();
			tmp=tmp&h[i];
			tmp=tmp&l[j];
			tmp=tmp&dj[i-j+2000];
			if(i>=3&&j>=2)tmp[sg[i-2][j-1]]=0;
			if(i>=2&&j>=3)tmp[sg[i-1][j-2]]=0;
			sg[i][j]=tmp._Find_first();
			h[i][sg[i][j]]=0;
			l[j][sg[i][j]]=0;
			dj[i-j+2000][sg[i][j]]=0;
		}
	}
	/*for(int i=1;i<=25;i++)
	{
		for(int j=1;j<=25;j++)
		{
			printf("%d ",sg[i][j]);
		}
		printf("\n");
	}*/
	int t,k,yh,sth;
	int ansx,ansy;
	int zsth,zx,zy;
	t=read();
	bool flag;
	for(int greg=1;greg<=t;greg++)
	{
		yh=0;
		k=read();
		for(int i=1;i<=k;i++)
		{
			tx[i]=read();
			ty[i]=read();
			yh^=sg[tx[i]][ty[i]];
		}
		if(yh==0)
		{
			printf("-1 -1 -1\n");
			continue;
		}
		sth=0;
		zx=1000000000;
		zy=1000000000;
		for(sth=1;sth<=k;sth++)
		{
		ansx=tx[sth];
		ansy=ty[sth];
		//printf("%d\n",sth);
		flag=false;
		for(int i=1;i<=tx[sth]-1;i++)
		{
			if(sg[i][ty[sth]]==(yh^sg[tx[sth]][ty[sth]]))
			{
				if(i<ansx)
				{
					ansx=i;
					ansy=ty[sth];
				}
			}
		}
		if(flag==true)continue;
		for(int i=1;i<=ty[sth]-1;i++)
		{
			if(sg[tx[sth]][i]==(yh^sg[tx[sth]][ty[sth]]))
			{
				if(tx[sth]<ansx||(tx[sth]==ansx&&i<ansy))
				{
					ansx=tx[sth];
					ansy=i;
				}
			}
		}
		if(flag==true)continue;
		for(int i=1;i<=min(tx[sth],ty[sth])-1;i++)
		{
			if(sg[tx[sth]-i][ty[sth]-i]==(yh^sg[tx[sth]][ty[sth]]))
			{
				if(tx[sth]-i<ansx||(tx[sth]-i==ansx&&ty[sth]-i<ansy))
				{
					ansx=tx[sth]-i;
					ansy=ty[sth]-i;
				}
			}
		}
		if(flag==true)continue;
		if(tx[sth]>=3&&ty[sth]>=2)
		{
			//printf("orz%d %d %d\n",sg[tx[sth]-2][ty[sth]-1],yh,sg[tx[sth]][ty[sth]]);
			if(sg[tx[sth]-2][ty[sth]-1]==(yh^sg[tx[sth]][ty[sth]]))
			{
				if(tx[sth]-2<ansx||(tx[sth]-2==ansx&&ty[sth]-1<ansy))
				{
					ansx=tx[sth]-2;
					ansy=ty[sth]-1;
				}
			}
		}
		if(flag==true)continue;
		if(tx[sth]>=2&&ty[sth]>=3)
		{
			if(sg[tx[sth]-1][ty[sth]-2]==(yh^sg[tx[sth]][ty[sth]]))
			{
				if(tx[sth]-1<ansx||(tx[sth]-1==ansx&&ty[sth]-2<ansy))
				{
					ansx=tx[sth]-1;
					ansy=ty[sth]-2;
				}
			}
		}
		if(ansx==tx[sth]&&ansy==ty[sth])continue;
		if(ansx<zx||(ansx==zx&&ansy<zy))
		{
			zsth=sth;
			zx=ansx;
			zy=ansy;
		}
		break;
		}
		printf("%d %d %d\n",zsth,zx,zy);
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 848ms
memory: 28308kb

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: 838ms
memory: 28248kb

input:

1
1
1 1

output:

-1 -1 -1

result:

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

Test #3:

score: 0
Accepted
time: 839ms
memory: 28268kb

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: 853ms
memory: 28156kb

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: 835ms
memory: 28148kb

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: 780ms
memory: 28240kb

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: 784ms
memory: 28240kb

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: 782ms
memory: 28248kb

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: 0
Accepted
time: 824ms
memory: 28188kb

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 1000 2000
2 293 1537
2 1956 1638
6 411 778
1 82 549
1 1312 528
4 776 700
1 115 17
9 1021 283
9 411 1800
1 236 1082
1 849 1864
1 627 1550
1 679 605
9 1531 716
2 1734 493
9 1032 1455
4 484 204
1 464 607
3 899 541
1 126 1350
1 256 681
4 500 1909
1 265 627
2 510 763
1 198 831
1 507 263
5 153 1879
1 38...

result:

ok 100 lines

Test #10:

score: 0
Accepted
time: 842ms
memory: 28184kb

input:

100
10
174 1612
1108 30
837 1521
1798 1450
705 1384
1756 1780
392 863
1098 1142
671 321
157 822
10
1063 1231
403 227
1849 230
994 772
847 1990
695 1287
1813 1210
1332 1205
1959 1277
1302 1512
10
792 940
306 329
1274 877
594 332
1565 495
910 209
1217 1723
1245 1742
1903 1587
1648 95
10
864 64
1220 13...

output:

1 44 1482
5 68 1990
7 1217 1339
1 414 64
7 291 622
8 67 650
4 258 1850
2 804 1828
2 503 381
7 633 975
2 254 37
1 78 364
1 604 1887
4 723 391
3 1772 1492
2 544 145
9 1062 881
4 389 1990
3 29 469
1 265 1897
1 1018 940
2 77 75
5 336 223
1 426 1033
3 982 1837
1 199 1844
1 875 1529
3 405 695
1 960 524
1 ...

result:

ok 100 lines

Test #11:

score: 0
Accepted
time: 807ms
memory: 28228kb

input:

100
10
841 648
1908 1886
1129 121
1083 93
701 1466
104 1343
1883 1339
8 607
628 551
323 794
10
1632 1048
604 424
915 926
1034 157
1963 622
1273 1743
1288 1986
800 201
968 1721
1106 834
10
983 113
936 792
1738 1465
4 619
484 740
241 267
124 1689
1386 1133
1292 1466
673 832
10
712 288
1958 973
1442 10...

output:

7 572 28
6 383 1743
9 599 1466
2 1958 866
-1 -1 -1
1 1386 308
-1 -1 -1
3 400 1757
1 197 670
-1 -1 -1
1 724 1363
-1 -1 -1
4 557 877
3 313 145
2 1510 1739
1 1075 845
-1 -1 -1
4 804 746
3 223 1962
1 434 382
7 1493 365
2 1884 321
7 734 1584
2 117 1461
-1 -1 -1
1 59 349
4 242 229
1 226 1352
7 27 1838
1 1...

result:

ok 100 lines

Test #12:

score: 0
Accepted
time: 815ms
memory: 28260kb

input:

100
10
1878 573
136 1130
440 811
1748 1227
330 1106
1345 552
114 874
1743 1089
1675 771
843 15
10
1768 86
1527 1666
226 215
238 31
340 1467
558 1777
1076 133
215 1825
1941 385
1671 765
10
1333 409
1238 1376
855 134
303 1015
134 1993
283 530
121 452
1051 419
560 1274
1892 394
10
1198 1583
29 764
1486...

output:

-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
1 551 1880
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
1 47 992
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-...

result:

ok 100 lines

Test #13:

score: 0
Accepted
time: 778ms
memory: 28240kb

input:

100
10
827 1286
778 606
1659 816
1486 858
1125 735
1130 1441
1196 1891
1152 11
1079 524
1568 590
10
1989 1826
777 1234
1386 1384
442 616
1101 1739
1440 498
1238 1159
1223 937
306 612
1675 1459
10
1164 1149
739 1374
1554 1799
852 779
669 1860
1681 761
804 122
818 1992
1081 50
978 1154
10
1122 749
194...

output:

-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 -1 -1
-1 ...

result:

ok 100 lines