QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#265209#7740. Puzzle: Question Markucup-team266#AC ✓223ms19188kbC++203.8kb2023-11-25 17:15:072023-11-25 17:15:08

Judging History

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

  • [2023-11-25 17:15:08]
  • 评测
  • 测评结果:AC
  • 用时:223ms
  • 内存:19188kb
  • [2023-11-25 17:15:07]
  • 提交

answer

/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
 
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts 
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest

9. module on time 
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
int n;
int ans[2005][2005],idx;
void fill1(int x1,int y1)
{
	idx++;
	ans[x1][y1]=ans[x1][y1+1]=ans[x1+1][y1]=ans[x1+1][y1+2]=idx;
	idx++;
	ans[x1+1][y1+1]=ans[x1][y1+2]=ans[x1][y1+3]=ans[x1+1][y1+3]=idx;
}
void fill2(int x1,int y1)
{
	idx++;
	ans[x1][y1]=ans[x1][y1+1]=ans[x1+1][y1]=ans[x1+2][y1+1]=idx;
	idx++;
	ans[x1+1][y1+1]=ans[x1+2][y1]=ans[x1+3][y1]=ans[x1+3][y1+1]=idx;
}
void print()
{
	cout<<idx<<"\n";
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++) cout<<ans[i][j]<<(j==n?"\n":" ");
//		for(int j=1;j<=n;j++) cout<<left<<setw(4)<<ans[i][j]<<" ";
//		cout<<"\n";
	}
}
int ans5[5][5]={
	{0,4,4,0,0},
	{5,4,5,3,3},
	{5,5,4,3,0},
	{1,1,2,2,3},
	{1,2,1,2,0}
};
int ans9[9][9]={
	{1,2,1,2,19,19,20,18,18},
{1,1,2,2,19,20,19,17,18},
{3,4,4,6,6,20,20,18,17},
{4,3,4,5,6,11,11,17,17},
{3,3,5,6,0,12,11,16,16},
{7,7,5,5,12,11,15,16,15},
{8,7,9,9,12,12,15,15,16},
{7,8,9,10,10,13,13,14,14},
{8,8,10,9,10,13,14,13,14}
};
void solve()
{
	
	cin>>n;
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) ans[i][j]=0;
	idx=0;
	if(n==1)
	{
		cout<<"0\n0\n";
		return;
	}
	if(n==2)
	{
		cout<<"0\n0 0\n0 0\n";
		return;
	}
	if(n==3)
	{
		cout<<"2\n0 1 1\n2 2 1\n2 1 2\n";
		return;
	}
	int flg=0;
	if(n==5||n==7)
	{
		if(n==7) flg=1,n-=2;
		idx=5;
		for(int i=1;i<=5;i++) for(int j=1;j<=5;j++) ans[i][j]=ans5[i-1][j-1];
		if(flg)
		{
			for(int i=1;i<n;i+=4) fill1(n+1,i),fill2(i,n+1);
		
			idx++;
			ans[n+1][n]=ans[n+2][n]=ans[n+2][n+1]=ans[n+1][n+2]=idx;
			idx++;
			ans[n][n+1]=ans[n][n+2]=ans[n+1][n+1]=ans[n+2][n+2]=idx;
			n+=2;
		}
		print();
		return;
	}
	if(n%2==0)
	{
		for(int i=1;i<=n/4*4;i++) for(int j=1;j<=n/4*4;j++) if(i%2==1&&j%4==1&&i+1<=n&&j+3<=n) fill1(i,j);
		if(n%4==2) 
		{
			for(int i=1;i+3<=n;i+=4) fill1(n-1,i),fill2(i,n-1);
		}
		print();
		return;
	}
	
	if(n%4==3) flg=1,n-=2;
	int st=(n+1)/2-4;
	idx=20;
	for(int i=0;i<9;i++) for(int j=0;j<9;j++) ans[st+i][1+j]=ans9[i][j];
	for(int i=9,L=st,R=st+8;i<n;i+=4,L-=2,R+=2)
	{
		idx++;
		int x=R,y=i;
		ans[x+1][y]=ans[x+2][y]=ans[x+2][y+1]=ans[x+1][y+2]=idx;
		idx++;
		ans[x][y+1]=ans[x][y+2]=ans[x+1][y+1]=ans[x+2][y+2]=idx;
		
		idx++;
		x=L,y=i;
		ans[x-2][y]=ans[x-2][y+1]=ans[x-1][y]=ans[x][y+1]=idx;
		idx++;
		ans[x-1][y+1]=ans[x][y+2]=ans[x+1][y+1]=ans[x+1][y+2]=idx;
		
		idx++;
		ans[x+3][y+1]=ans[x+3][y+2]=ans[x+2][y+1]=ans[x+2][y+3]=idx;
		idx++;
		ans[x+2][y+2]=ans[x+2][y+4]=ans[x+1][y+3]=ans[x+1][y+4]=idx;
		
		idx++;
		ans[x-2][y+2]=ans[x-2][y+3]=ans[x-1][y+2]=ans[x-1][y+4]=idx;
		idx++;
		ans[x-2][y+4]=ans[x-1][y+3]=ans[x][y+3]=ans[x][y+4]=idx;
		for(int j=1;j<i;j+=4) fill1(L-2,j),fill1(R+1,j);
		for(int j=L+4;ans[j][i+1]==0;j+=4) fill2(j,i+1);
		for(int j=L+3;j<=R;j+=4) fill2(j,i+3);
	}
	if(flg) 
	{
		for(int i=1;i<n;i+=4) fill1(n+1,i),fill2(i,n+1);
		
		idx++;
		ans[n+1][n]=ans[n+2][n]=ans[n+2][n+1]=ans[n+1][n+2]=idx;
		idx++;
		ans[n][n+1]=ans[n][n+2]=ans[n+1][n+1]=ans[n+2][n+2]=idx;
		n+=2;
	}
	print();
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int _=1;
	cin>>_;
	while(_--) solve();
	return 0;
}

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

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3428kb

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: 200ms
memory: 6576kb

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 4 4 0 0
5 4 5 3 3
5 5 4 3 0
1 1 2 2 3
1 2 1 2 0
8
1 1 2 2 7 7
1 2 1 2 7 8
3 3 4 4 8 7
3 4 3 4 8 8
5 5 6 6 0 0
5 6 5 6 0 0
11
0 4 4 0 0 8 8
5 4 5 3 3 8 9
5 5 4 3 0 9 8
1 1 2 2 3 9 9
1 2 1 2 0 11 11
6 6 7 7 10 11 10
6 7 6 7 10 10 ...

result:

ok Correct. (246 test cases)

Test #3:

score: 0
Accepted
time: 178ms
memory: 6084kb

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
14529 14529 14530 14530 14533 14533 14534 14534 14537 14537 14538 14538 14541 14541 14542 14542 14545 14545 14546 14546 14549 14549 14550 14550 14553 14553 14554 14554 14557 14557 14558 14558 14561 14561 14562 14562 14565 14565 14566 14566 14569 14569 14570 14570 14573 14573 14574 14574 14577 ...

result:

ok Correct. (64 test cases)

Test #4:

score: 0
Accepted
time: 197ms
memory: 6772kb

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
23265 23265 23266 23266 23269 23269 23270 23270 23273 23273 23274 23274 23277 23277 23278 23278 23281 23281 23282 23282 23285 23285 23286 23286 23289 23289 23290 23290 23293 23293 23294 23294 23297 23297 23298 23298 23301 23301 23302 23302 23305 23305 23306 23306 23309 23309 23310 23310 23313 ...

result:

ok Correct. (45 test cases)

Test #5:

score: 0
Accepted
time: 202ms
memory: 6516kb

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: 186ms
memory: 7872kb

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
37065 37065 37066 37066 37069 37069 37070 37070 37073 37073 37074 37074 37077 37077 37078 37078 37081 37081 37082 37082 37085 37085 37086 37086 37089 37089 37090 37090 37093 37093 37094 37094 37097 37097 37098 37098 37101 37101 37102 37102 37105 37105 37106 37106 37109 37109 37110 37110 37113 ...

result:

ok Correct. (30 test cases)

Test #7:

score: 0
Accepted
time: 215ms
memory: 19188kb

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: 215ms
memory: 19176kb

input:

2
1999
999

output:

999000
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 993053 993054 993054 993057 993057 993058 993058 993061 993061...

result:

ok Correct. (2 test cases)

Test #9:

score: 0
Accepted
time: 196ms
memory: 19048kb

input:

2
1998
998

output:

998000
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 #10:

score: 0
Accepted
time: 207ms
memory: 19024kb

input:

2
1997
997

output:

997002
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 993053 993054 993054 993057 993057 993058 993058 993061 993061...

result:

ok Correct. (2 test cases)

Test #11:

score: 0
Accepted
time: 199ms
memory: 19016kb

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: 223ms
memory: 18984kb

input:

2
1995
995

output:

995006
989039 989039 989040 989040 989043 989043 989044 989044 989047 989047 989048 989048 989051 989051 989052 989052 989055 989055 989056 989056 989059 989059 989060 989060 989063 989063 989064 989064 989067 989067 989068 989068 989071 989071 989072 989072 989075 989075 989076 989076 989079 989079...

result:

ok Correct. (2 test cases)

Test #13:

score: 0
Accepted
time: 209ms
memory: 19012kb

input:

2
1994
994

output:

994008
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 #14:

score: 0
Accepted
time: 223ms
memory: 18972kb

input:

2
1993
993

output:

993012
989039 989039 989040 989040 989043 989043 989044 989044 989047 989047 989048 989048 989051 989051 989052 989052 989055 989055 989056 989056 989059 989059 989060 989060 989063 989063 989064 989064 989067 989067 989068 989068 989071 989071 989072 989072 989075 989075 989076 989076 989079 989079...

result:

ok Correct. (2 test cases)

Test #15:

score: 0
Accepted
time: 192ms
memory: 19000kb

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: 189ms
memory: 19112kb

input:

2
1991
991

output:

991020
985065 985065 985066 985066 985069 985069 985070 985070 985073 985073 985074 985074 985077 985077 985078 985078 985081 985081 985082 985082 985085 985085 985086 985086 985089 985089 985090 985090 985093 985093 985094 985094 985097 985097 985098 985098 985101 985101 985102 985102 985105 985105...

result:

ok Correct. (2 test cases)

Extra Test:

score: 0
Extra Test Passed