QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22300#2353. Maharajas are Going HomeMr_Eight#WA 171ms21344kbC++143.4kb2022-03-09 14:47:352022-04-30 00:52:13

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 00:52:13]
  • 评测
  • 测评结果:WA
  • 用时:171ms
  • 内存:21344kb
  • [2022-03-09 14:47:35]
  • 提交

answer

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <climits>
#include <functional>
#include <cstring>
#include <string>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
//#include <random>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
#define itn int
#define nit int
#define ll long long
#define ms multiset
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define re register
#define ri re int
#define il inline
#define pii pair<int,int>
#define cp complex<double>
#define vi vector<int>
#define ull unsigned long long
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
using namespace std;
//using namespace __gnu_pbds;
const double Pi=acos(-1);
namespace fastIO {
	template<class T>
	inline void read(T &x) {
		x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		if(fu)x=-x;
	}
	inline int read() {
		int x=0;
		bool fu=0;
		char ch=0;
		while(ch>'9'||ch<'0') {
			ch=getchar();
			if(ch=='-')fu=1;
		}
		while(ch<='9'&&ch>='0') x=(x*10-48+ch),ch=getchar();
		return fu?-x:x;
	}
	template<class T,class... Args>
	inline void read(T& t,Args&... args) {
		read(t);
		read(args...);
	}
	char _n_u_m_[40];
	template<class T>
	inline void write(T x) {
		if(x==0) {
			putchar('0');
			return;
		}
		T tmp = x > 0 ? x : -x ;
		if( x < 0 ) putchar('-') ;
		register int cnt = 0 ;
		while( tmp > 0 ) {
			_n_u_m_[ cnt ++ ] = tmp % 10 + '0' ;
			tmp /= 10 ;
		}
		while( cnt > 0 ) putchar(_n_u_m_[ -- cnt ]) ;
	}
	template<class T>
	inline void write(T x ,char ch) {
		write(x);
		putchar(ch);
	}
}
using namespace fastIO;
int sg[2002][2002];
bitset<2002>a[2002],b[2002],c[4002],temp;
int n,x[2002],y[2002];
int main() {
	n=2000;
	F(i,1,n) {
		F(j,1,n) {
			temp=a[i]|b[j]|c[i-j+2000];
			if(i>=3&&j>=2)temp[sg[i-2][j-1]]=1;
			if(i>=2&&j>=3)temp[sg[i-1][j-2]]=1;
			sg[i][j]=(~temp)._Find_first();
			a[i][sg[i][j]]=b[j][sg[i][j]]=c[i-j+2000][sg[i][j]]=1;
		}
	}
	F(iak,1,read()) {
		int k=read(),s=0;
		F(i,1,k)read(x[i],y[i]),s^=sg[x[i]][y[i]];
		if(!s)puts("-1 -1 -1");
		else {
			bool flag=false;
			auto ans=make_pair(114514,114514);
			F(i,1,k) {
				UF(j,x[i]-1,1) {
					if(j<y[i]) {
						if(!(s^sg[x[i]][y[i]]^sg[x[i]-j][y[i]-j])) {
							ans=min(ans,make_pair(x[i]-j,y[i]-j));
						}
					}
					if(!(s^sg[x[i]][y[i]]^sg[x[i]-j][y[i]])) {
						ans=min(ans,make_pair(x[i]-j,y[i]));
					}
				}
				UF(j,y[i]-1,1) {
					if(!(s^sg[x[i]][y[i]]^sg[x[i]][y[i]-j])) {
						ans=min(ans,make_pair(x[i],y[i]-j));
					}
				}

				if(x[i]>2&&y[i]>1) {
					if(!(s^sg[x[i]-2][y[i]-1]^sg[x[i]][y[i]])) {
						ans=min(ans,make_pair(x[i]-2,y[i]-1));
					}
				}
				if(x[i]>1&&y[i]>2) {
					if(!(s^sg[x[i]-1][y[i]-2]^sg[x[i]][y[i]])) {
						ans=min(ans,make_pair(x[i]-1,y[i]-2));
					}
				}
				if(ans.first<1e5) {
					write(i,' ');
					write(ans.first,' ');
					write(ans.second,'\n');
					flag=true;
					break;
				}
			}
			if(!flag)while(true);
		}
	}

return 0;
}

详细

Test #1:

score: 100
Accepted
time: 160ms
memory: 21344kb

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: 156ms
memory: 21248kb

input:

1
1
1 1

output:

-1 -1 -1

result:

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

Test #3:

score: 0
Accepted
time: 153ms
memory: 21120kb

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: 156ms
memory: 21236kb

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: 154ms
memory: 21200kb

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: 166ms
memory: 21336kb

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: 167ms
memory: 21120kb

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: 155ms
memory: 21236kb

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: 171ms
memory: 21120kb

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 216 2000
2 191 1435
1 68 63
2 151 883
1 82 549
1 1296 480
2 383 359
1 115 632
1 203 997
1 24 1940
1 236 1082
1 189 1864
1 1426 1458
1 742 668
1 875 513
1 765 176
1 550 925
1 18 273
1 464 607
3 692 541
1 126 1350
1 256 681
2 421 787
1 265 627
1 206 700
1 198 912
1 507 263
2 1047 1576
1 731 1545
1 4...

result:

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