QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#242872#7740. Puzzle: Question Markucup-team203AC ✓237ms19580kbC++145.9kb2023-11-07 17:57:092023-11-07 17:57:10

Judging History

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

  • [2023-11-07 17:57:10]
  • 评测
  • 测评结果:AC
  • 用时:237ms
  • 内存:19580kb
  • [2023-11-07 17:57:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int model8_1[4][2]={{1,1},
                  {1,2},
                  {2,1},
                  {2,2}};
int model8_2[2][4]={{1,1,2,2},
                    {1,2,1,2}};
int model9[3][3]={{0,1,1},
                  {2,1,2},
                  {2,2,1}};
int model9_1[3][3]={{2,2,1},
                    {2,1,2},
                    {0,1,1}};
int model12_1[3][4]={{2,2,0,0},
                     {2,1,2,1},
                     {0,0,1,1}};
int model12_2[4][3]={{0,2,2},
                     {0,1,2},
                     {1,2,0},
                     {1,1,0}};

int model4[2][2]={{0,0},{0,0}};
int model25[5][5]={{1,1,2,0,2},
                   {1,3,1,2,2},
                   {3,4,4,5,5},
                   {3,3,4,5,0},
                   {0,4,0,0,5}};
int model49[7][7]={{1,1,2,0,2,6,6},
                   {1,3,1,2,2,6,7},
                   {3,4,4,5,5,7,6},
                   {3,3,4,5,0,7,7},
                   {0,4,0,0,5,8,8},
                   {10,10,11,11,9,9,8},
                   {10,11,10,11,9,8,9}};
int model81[9][9]={{ 1, 1, 2, 3, 2, 4, 4, 5, 5},
                   { 6, 1, 3, 2, 2, 4, 5, 4, 5},
                   { 1, 6, 3, 3, 7, 7, 8, 8, 9},
                   { 6, 6,10,10, 7,11, 8, 9, 8},
                   {12,12,10,13, 0, 7,11, 9, 9},
                   {12,14,14,10,13,11,11,15,15},
                   {14,12,14,13,13,16,16,17,15},
                   {18,18,19,19,20,20,16,15,17},
                   {18,19,18,19,20,16,20,17,17}};
int a[2020][2020];
void cop8_1(int x,int y,int &now)
{
    for(int i=0;i<4;i++)
        for(int j=0;j<2;j++)
            a[x+i][y+j]=model8_1[i][j]+now;
    now+=2;
}
void cop8_2(int x,int y,int &now)
{
    for(int i=0;i<2;i++)
        for(int j=0;j<4;j++)
            a[x+i][y+j]=model8_2[i][j]+now;
    now+=2;
}
void cop9(int x,int y,int &now)
{
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
        {
            if(model9[i][j]==0)continue;
            a[x+i][y+j]=model9[i][j]+now;
        }        
    now+=2;
}
void cop9_1(int x,int y,int &now)
{
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
        {
            if(model9_1[i][j]==0)continue;
            a[x+i][y+j]=model9_1[i][j]+now;
        }        
    now+=2;
}
void cop25(int x,int y,int &now)
{
    for(int i=0;i<5;i++)
        for(int j=0;j<5;j++)
        {
            if(model25[i][j]==0)continue;
            a[x+i][y+j]=model25[i][j]+now;
        }        
    now+=5;
}
void cop49(int x,int y,int &now)
{
    for(int i=0;i<7;i++)
        for(int j=0;j<7;j++)
        {
            if(model49[i][j]==0)continue;
            a[x+i][y+j]=model49[i][j]+now;
        }     
    
    now+=11;   
}
void cop81(int x,int y,int &now)
{
    for(int i=0;i<9;i++)
        for(int j=0;j<9;j++)
        {
            if(model81[i][j]==0)continue;
            a[x+i][y+j]=model81[i][j]+now;
        }        
    
    now+=20;
}
void cop12_1(int x,int y,int &now)
{
    for(int i=0;i<3;i++)
        for(int j=0;j<4;j++)
        {
            if(model12_1[i][j]==0)continue;
            a[x+i][y+j]=model12_1[i][j]+now;
        }        
    
    now+=2;
}
void cop12_2(int x,int y,int &now)
{
    for(int i=0;i<4;i++)
        for(int j=0;j<3;j++)
        {
            if(model12_2[i][j]==0)continue;
            a[x+i][y+j]=model12_2[i][j]+now;
        }        
    
    now+=2;
}
void output(int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n-1;j++)
            printf("%d ",a[i][j]);
        printf("%d\n",a[i][n-1]);
    }
}
void full_1(int &x,int &y,int &now,int n)
{
    for(int i=0;i+5<n;i+=4)cop8_2(x+0,y+i,now),cop8_2(x+n-2,y+i,now);
    cop9_1(x+0,y+n-5,now);
    cop8_1(x+0,y+n-2,now);
    for(int j=3;j+6<n;j+=4)
    {
        cop8_1(x+j,y+n-4,now);
        cop8_1(x+j+1,y+n-2,now);
    }
    cop12_1(x+n-6,y+n-4,now);
    // output(13);
    cop12_2(x+n-4,y+n-5,now);
    cop9(x+n-3,y+n-3,now);
    x+=2;
}
void solve()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            a[i][j]=0;
    int k=n/4;
    if(n==4*k)
    {
        printf("%d\n",n*n/4);
        int now=0;
        for(int i=0;i<n;i+=4)
        {
            for(int j=0;j<n;j+=2)
            {
                cop8_1(i,j,now);
            }
        }
        output(n);
        return;
    }
    if(n==4*k+2)
    {
        printf("%d\n",n*n/4-1);
        int now=0;
        for(int i=0;i+4<=n;i+=4)
        {
            for(int j=0;j+2<=n;j+=2)
            {
                cop8_1(i,j,now);
            }
        }
        for(int j=0;j+4<=n;j+=4)
        {
            cop8_2(n-2,j,now);
        }
        output(n);
        return;
    }
    if(n==1)
    {
        printf("%d\n",0);
        // cop9(0,0,0);
        output(n);
        return;
    }
    if(n==3)
    {
        int now=0;
        printf("%d\n",2);
        cop9(0,0,now);
        output(n);
        return;
    }
    if(n==5)
    {
        int now=0;
        printf("%d\n",5);
        cop25(0,0,now);
        output(n);
        return;
    }
    if(n==7)
    {
        int now=0;
        printf("%d\n",11);
        cop49(0,0,now);
        output(n);
        return;
    }
    if(n==4*k+1)
    {
        
        printf("%d\n",n*n/4);
        int x=0,y=0,now=0,p=n;
        while(n!=9)
        {
            full_1(x,y,now,n);
            n-=4;
        }   
        cop81(x,y,now);
        output(p);
        return;
    }
    if(n==4*k+3)
    {
        
        printf("%d\n",n*n/4);
        int x=0,y=0,now=0,p=n-2;
        while(p!=9)
        {
            full_1(x,y,now,p);
            p-=4;
        }   
        cop81(x,y,now);
        for(int i=0;i+4<n;i+=4)cop8_1(i,n-2,now),cop8_2(n-2,i,now);
        cop9(n-3,n-3,now);
        output(n);
        return;
    }
}
int main()
{
    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: 1ms
memory: 3560kb

input:

2
3
4

output:

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

result:

ok Correct. (2 test cases)

Test #2:

score: 0
Accepted
time: 185ms
memory: 6992kb

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

result:

ok Correct. (246 test cases)

Test #3:

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

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
1 1 2 2 5 5 6 6 9 9 10 10 13 13 14 14 17 17 18 18 21 21 22 22 25 25 26 26 29 29 30 30 33 33 34 34 37 37 38 38 41 41 42 42 45 45 46 46 49 49 50 50 53 53 54 54 57 57 58 58 61 61 62 62 65 65 66 66 69 69 70 70 73 73 74 74 77 77 78 78 81 81 82 82 85 85 86 86 89 89 90 90 93 93 94 94 97 97 98 98 101 ...

result:

ok Correct. (64 test cases)

Test #4:

score: 0
Accepted
time: 206ms
memory: 6200kb

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
1 1 2 2 5 5 6 6 9 9 10 10 13 13 14 14 17 17 18 18 21 21 22 22 25 25 26 26 29 29 30 30 33 33 34 34 37 37 38 38 41 41 42 42 45 45 46 46 49 49 50 50 53 53 54 54 57 57 58 58 61 61 62 62 65 65 66 66 69 69 70 70 73 73 74 74 77 77 78 78 81 81 82 82 85 85 86 86 89 89 90 90 93 93 94 94 97 97 98 98 101 ...

result:

ok Correct. (45 test cases)

Test #5:

score: 0
Accepted
time: 217ms
memory: 6896kb

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 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101 ...

result:

ok Correct. (35 test cases)

Test #6:

score: 0
Accepted
time: 218ms
memory: 7004kb

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
1 1 2 2 5 5 6 6 9 9 10 10 13 13 14 14 17 17 18 18 21 21 22 22 25 25 26 26 29 29 30 30 33 33 34 34 37 37 38 38 41 41 42 42 45 45 46 46 49 49 50 50 53 53 54 54 57 57 58 58 61 61 62 62 65 65 66 66 69 69 70 70 73 73 74 74 77 77 78 78 81 81 82 82 85 85 86 86 89 89 90 90 93 93 94 94 97 97 98 98 101 ...

result:

ok Correct. (30 test cases)

Test #7:

score: 0
Accepted
time: 229ms
memory: 19296kb

input:

2
2000
1000

output:

1000000
1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 10...

result:

ok Correct. (2 test cases)

Test #8:

score: 0
Accepted
time: 218ms
memory: 19536kb

input:

2
1999
999

output:

999000
1 1 2 2 5 5 6 6 9 9 10 10 13 13 14 14 17 17 18 18 21 21 22 22 25 25 26 26 29 29 30 30 33 33 34 34 37 37 38 38 41 41 42 42 45 45 46 46 49 49 50 50 53 53 54 54 57 57 58 58 61 61 62 62 65 65 66 66 69 69 70 70 73 73 74 74 77 77 78 78 81 81 82 82 85 85 86 86 89 89 90 90 93 93 94 94 97 97 98 98 101...

result:

ok Correct. (2 test cases)

Test #9:

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

input:

2
1998
998

output:

998000
1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101...

result:

ok Correct. (2 test cases)

Test #10:

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

input:

2
1997
997

output:

997002
1 1 2 2 5 5 6 6 9 9 10 10 13 13 14 14 17 17 18 18 21 21 22 22 25 25 26 26 29 29 30 30 33 33 34 34 37 37 38 38 41 41 42 42 45 45 46 46 49 49 50 50 53 53 54 54 57 57 58 58 61 61 62 62 65 65 66 66 69 69 70 70 73 73 74 74 77 77 78 78 81 81 82 82 85 85 86 86 89 89 90 90 93 93 94 94 97 97 98 98 101...

result:

ok Correct. (2 test cases)

Test #11:

score: 0
Accepted
time: 237ms
memory: 19496kb

input:

2
1996
996

output:

996004
1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101...

result:

ok Correct. (2 test cases)

Test #12:

score: 0
Accepted
time: 210ms
memory: 19580kb

input:

2
1995
995

output:

995006
1 1 2 2 5 5 6 6 9 9 10 10 13 13 14 14 17 17 18 18 21 21 22 22 25 25 26 26 29 29 30 30 33 33 34 34 37 37 38 38 41 41 42 42 45 45 46 46 49 49 50 50 53 53 54 54 57 57 58 58 61 61 62 62 65 65 66 66 69 69 70 70 73 73 74 74 77 77 78 78 81 81 82 82 85 85 86 86 89 89 90 90 93 93 94 94 97 97 98 98 101...

result:

ok Correct. (2 test cases)

Test #13:

score: 0
Accepted
time: 229ms
memory: 19340kb

input:

2
1994
994

output:

994008
1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101...

result:

ok Correct. (2 test cases)

Test #14:

score: 0
Accepted
time: 216ms
memory: 19296kb

input:

2
1993
993

output:

993012
1 1 2 2 5 5 6 6 9 9 10 10 13 13 14 14 17 17 18 18 21 21 22 22 25 25 26 26 29 29 30 30 33 33 34 34 37 37 38 38 41 41 42 42 45 45 46 46 49 49 50 50 53 53 54 54 57 57 58 58 61 61 62 62 65 65 66 66 69 69 70 70 73 73 74 74 77 77 78 78 81 81 82 82 85 85 86 86 89 89 90 90 93 93 94 94 97 97 98 98 101...

result:

ok Correct. (2 test cases)

Test #15:

score: 0
Accepted
time: 217ms
memory: 19364kb

input:

2
1992
992

output:

992016
1 1 3 3 5 5 7 7 9 9 11 11 13 13 15 15 17 17 19 19 21 21 23 23 25 25 27 27 29 29 31 31 33 33 35 35 37 37 39 39 41 41 43 43 45 45 47 47 49 49 51 51 53 53 55 55 57 57 59 59 61 61 63 63 65 65 67 67 69 69 71 71 73 73 75 75 77 77 79 79 81 81 83 83 85 85 87 87 89 89 91 91 93 93 95 95 97 97 99 99 101...

result:

ok Correct. (2 test cases)

Test #16:

score: 0
Accepted
time: 224ms
memory: 19184kb

input:

2
1991
991

output:

991020
1 1 2 2 5 5 6 6 9 9 10 10 13 13 14 14 17 17 18 18 21 21 22 22 25 25 26 26 29 29 30 30 33 33 34 34 37 37 38 38 41 41 42 42 45 45 46 46 49 49 50 50 53 53 54 54 57 57 58 58 61 61 62 62 65 65 66 66 69 69 70 70 73 73 74 74 77 77 78 78 81 81 82 82 85 85 86 86 89 89 90 90 93 93 94 94 97 97 98 98 101...

result:

ok Correct. (2 test cases)

Extra Test:

score: 0
Extra Test Passed