QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#345522#7740. Puzzle: Question MarkSorting#AC ✓181ms19324kbC++203.1kb2024-03-07 04:42:382024-03-07 04:42:39

Judging History

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

  • [2024-03-07 04:42:39]
  • 评测
  • 测评结果:AC
  • 用时:181ms
  • 内存:19324kb
  • [2024-03-07 04:42:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int ts=262144;
int n,m,o;
int a[2005][2005];
int r[2][4]={{1,1,2,2},{1,2,1,2}};
void fill24(int x,int y){
	for(int i=0; i<2 ;i++){
		for(int j=0; j<4 ;j++){
			a[x+i+o][y+j+o]=m+r[i][j];
		}
	}
	m+=2;
}
void fill42(int x,int y){
	for(int i=0; i<4 ;i++){
		for(int j=0; j<2 ;j++){
			a[x+i+o][y+j+o]=m+r[j][i];
		}
	}
	m+=2;
}
int frog[4][5]={
{1,1,3,3,4},
{1,2,3,4,3},
{0,1,2,4,4},
{0,2,2,0,0},
};
int toad[3][3]={
{1,2,1},
{2,1,1},
{2,2,0}
};
void bang(int n){
	if(n<=2) return;
	if(n==5){
		a[n-2+o][n-1+o]=a[n-2+o][n+o]=a[n-1+o][n+o]=a[n+o][n-1+o]=m+1;
		a[n-1+o][n-2+o]=a[n-1+o][n-1+o]=a[n+o][n-2+o]=a[n+o][n+o]=m+2;
		m+=2;
		fill24(1,2);
		a[3+o][1+o]=a[4+o][2+o]=a[5+o][1+o]=a[5+o][2+o]=m+1;
		++m;
		return;
		
	}
	if(n%4==0){
		for(int i=1; i<=n ;i+=2){
			for(int j=1; j<=n ;j+=4){
				fill24(i,j);
			}
		}
		return;
	}
	if(n%4==2){
		for(int i=1; i<=n-4 ;i+=4){
			fill24(n-1,i);
			fill42(i,n-1);
		}
		bang(n-2);
		return;
	}
	if(n%4==3){
		for(int i=1; i<=n-4 ;i+=4){
			fill24(n-1,i);
			fill42(i,n-1);
		}
		a[n-2+o][n-1+o]=a[n-2+o][n+o]=a[n-1+o][n+o]=a[n+o][n-1+o]=m+1;
		a[n-1+o][n-2+o]=a[n-1+o][n-1+o]=a[n+o][n-2+o]=a[n+o][n+o]=m+2;
		m+=2;
		bang(n-2);
		return;
	}
	if(n%8==5){
		int save_o=o;
		int aespa=m;
		o+=2;
		bang(n-4);
		o=save_o;
		for(int i=0; i<3 ;i++){
			for(int j=0; j<3 ;j++){
				if(toad[i][j]==0) continue;
				a[i+1+o][j+1+o]=toad[i][j]+m;
				a[n-i+o][n-j+o]=toad[i][j]+m+2;
			}
		}
		m+=4;
		for(int i=6; i<=n ;i+=4){
			fill24(1,i);
			fill42(i,1);
		}
		for(int i=3; i<=n-3 ;i+=4){
			fill24(n-1,i);
			fill42(i,n-1);
		}
		a[3][3]=a[3][4]=a[4][2]=a[4][4]=aespa+1;
		a[4][1]=a[4][3]=a[5][1]=a[5][2]=aespa+2;
		a[1][4]=a[1][5]=a[2][4]=a[3][5]=m+1;
		a[2][5]=a[3][6]=a[4][5]=a[4][6]=m+2;
		m+=2;
		return;
	}
	if(n%4==1){
		for(int i=1; i<=n-5 ;i+=4){
			fill24(1,i);
		}
		for(int i=6; i<=n ;i+=4){
			fill24(n-1,i);
		}
		for(int i=3; i<=n-4 ;i+=4){
			fill42(i,1);
		}
		for(int i=4; i<=n-3 ;i+=4){
			fill42(i,n-1);
		}
		for(int i=0; i<4 ;i++){
			for(int j=0; j<5 ;j++){
				if(frog[i][j]==0) continue;
				a[i+1+o][n-4+j+o]=frog[i][j]+m;
				a[n-i+o][5-j+o]=frog[i][j]+m+4;
			}
		}
		m+=8;
		for(int i=6; i<=n-4 ;i+=4){
			fill24(3,i);
			fill42(i,3);
		}
		for(int i=5; i<=n-5 ;i+=4){
			fill24(n-3,i);
			fill42(i,n-3);
		}
		for(int i=0; i<3 ;i++){
			for(int j=0; j<3 ;j++){
				if(toad[i][j]==0) continue;
				a[i+3+o][j+3+o]=toad[i][j]+m;
				a[n-2-i+o][n-2-j+o]=toad[i][j]+m+2;
			}
		}
		m+=4;
		o+=4;
		bang(n-8);
		return;
	}
}
void solve(){
	cin >> n;m=0;o=0;
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=n ;j++){
			a[i][j]=0;
		}
	}
	bang(n);
	cout << m << '\n';
	for(int i=1; i<=n ;i++){
		for(int j=1; j<=n ;j++){
			//if(a[i][j]==0) cout << "0";
			cout << a[i][j] << " \n"[j==n];
		}
		//cout << '\n';
	}
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int t;cin >> t;while(t--) solve();
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3668kb

input:

2
3
4

output:

2
0 1 1
2 2 1
2 1 2
4
1 1 2 2
1 2 1 2
3 3 4 4
3 4 3 4

result:

ok Correct. (2 test cases)

Test #2:

score: 0
Accepted
time: 160ms
memory: 6544kb

input:

246
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...

output:

0
0
0
0 0
0 0
2
0 1 1
2 2 1
2 1 2
4
1 1 2 2
1 2 1 2
3 3 4 4
3 4 3 4
5
0 3 3 4 4
0 3 4 3 4
5 0 0 1 1
0 5 2 2 1
5 5 2 1 2
8
5 5 6 6 3 3
5 6 5 6 3 4
7 7 8 8 4 3
7 8 7 8 4 4
1 1 2 2 0 0
1 2 1 2 0 0
11
0 9 9 10 10 3 3
0 9 10 9 10 3 4
11 0 0 7 7 4 3
0 11 8 8 7 4 4
11 11 8 7 8 5 5
1 1 2 2 6 6 5
1 2 1 2 6 5...

result:

ok Correct. (246 test cases)

Test #3:

score: 0
Accepted
time: 152ms
memory: 6352kb

input:

64
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310

output:

15252
14767 14768 14767 15251 15251 14771 14771 14772 14772 14775 14775 14776 14776 14779 14779 14780 14780 14783 14783 14784 14784 14787 14787 14788 14788 14791 14791 14792 14792 14795 14795 14796 14796 14799 14799 14800 14800 14803 14803 14804 14804 14807 14807 14808 14808 14811 14811 14812 14812 ...

result:

ok Correct. (64 test cases)

Test #4:

score: 0
Accepted
time: 154ms
memory: 6272kb

input:

45
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355

output:

24180
23567 23568 23567 24179 24179 23571 23571 23572 23572 23575 23575 23576 23576 23579 23579 23580 23580 23583 23583 23584 23584 23587 23587 23588 23588 23591 23591 23592 23592 23595 23595 23596 23596 23599 23599 23600 23600 23603 23603 23604 23604 23607 23607 23608 23608 23611 23611 23612 23612 ...

result:

ok Correct. (45 test cases)

Test #5:

score: 0
Accepted
time: 150ms
memory: 7992kb

input:

35
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390

output:

31684
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 ...

result:

ok Correct. (35 test cases)

Test #6:

score: 0
Accepted
time: 157ms
memory: 6808kb

input:

30
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420

output:

38220
37447 37448 37447 38219 38219 37451 37451 37452 37452 37455 37455 37456 37456 37459 37459 37460 37460 37463 37463 37464 37464 37467 37467 37468 37468 37471 37471 37472 37472 37475 37475 37476 37476 37479 37479 37480 37480 37483 37483 37484 37484 37487 37487 37488 37488 37491 37491 37492 37492 ...

result:

ok Correct. (30 test cases)

Test #7:

score: 0
Accepted
time: 151ms
memory: 19252kb

input:

2
2000
1000

output:

1000000
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 5...

result:

ok Correct. (2 test cases)

Test #8:

score: 0
Accepted
time: 175ms
memory: 19228kb

input:

2
1999
999

output:

999000
995011 995012 995011 998999 998999 995015 995015 995016 995016 995019 995019 995020 995020 995023 995023 995024 995024 995027 995027 995028 995028 995031 995031 995032 995032 995035 995035 995036 995036 995039 995039 995040 995040 995043 995043 995044 995044 995047 995047 995048 995048 995051...

result:

ok Correct. (2 test cases)

Test #9:

score: 0
Accepted
time: 142ms
memory: 19256kb

input:

2
1998
998

output:

998000
1997 1997 1998 1998 1999 1999 2000 2000 2001 2001 2002 2002 2003 2003 2004 2004 2005 2005 2006 2006 2007 2007 2008 2008 2009 2009 2010 2010 2011 2011 2012 2012 2013 2013 2014 2014 2015 2015 2016 2016 2017 2017 2018 2018 2019 2019 2020 2020 2021 2021 2022 2022 2023 2023 2024 2024 2025 2025 202...

result:

ok Correct. (2 test cases)

Test #10:

score: 0
Accepted
time: 158ms
memory: 19288kb

input:

2
1997
997

output:

997002
993013 993014 993013 997001 997001 993017 993017 993018 993018 993021 993021 993022 993022 993025 993025 993026 993026 993029 993029 993030 993030 993033 993033 993034 993034 993037 993037 993038 993038 993041 993041 993042 993042 993045 993045 993046 993046 993049 993049 993050 993050 993053...

result:

ok Correct. (2 test cases)

Test #11:

score: 0
Accepted
time: 155ms
memory: 19288kb

input:

2
1996
996

output:

996004
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52...

result:

ok Correct. (2 test cases)

Test #12:

score: 0
Accepted
time: 181ms
memory: 19292kb

input:

2
1995
995

output:

995006
1995 1995 1996 1996 1997 1997 1998 1998 1999 1999 2000 2000 2001 2001 2002 2002 2003 2003 2004 2004 2005 2005 2006 2006 2007 2007 2008 2008 2009 2009 2010 2010 2011 2011 2012 2012 2013 2013 2014 2014 2015 2015 2016 2016 2017 2017 2018 2018 2019 2019 2020 2020 2021 2021 2022 2022 2023 2023 202...

result:

ok Correct. (2 test cases)

Test #13:

score: 0
Accepted
time: 144ms
memory: 19292kb

input:

2
1994
994

output:

994008
1993 1993 1994 1994 1995 1995 1996 1996 1997 1997 1998 1998 1999 1999 2000 2000 2001 2001 2002 2002 2003 2003 2004 2004 2005 2005 2006 2006 2007 2007 2008 2008 2009 2009 2010 2010 2011 2011 2012 2012 2013 2013 2014 2014 2015 2015 2016 2016 2017 2017 2018 2018 2019 2019 2020 2020 2021 2021 202...

result:

ok Correct. (2 test cases)

Test #14:

score: 0
Accepted
time: 166ms
memory: 19176kb

input:

2
1993
993

output:

993012
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52...

result:

ok Correct. (2 test cases)

Test #15:

score: 0
Accepted
time: 152ms
memory: 19236kb

input:

2
1992
992

output:

992016
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52...

result:

ok Correct. (2 test cases)

Test #16:

score: 0
Accepted
time: 174ms
memory: 19324kb

input:

2
1991
991

output:

991020
987047 987048 987047 991019 991019 987051 987051 987052 987052 987055 987055 987056 987056 987059 987059 987060 987060 987063 987063 987064 987064 987067 987067 987068 987068 987071 987071 987072 987072 987075 987075 987076 987076 987079 987079 987080 987080 987083 987083 987084 987084 987087...

result:

ok Correct. (2 test cases)

Extra Test:

score: 0
Extra Test Passed