QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#267322#7740. Puzzle: Question MarkLynkcatAC ✓226ms51780kbC++205.8kb2023-11-27 09:08:302023-11-27 09:08:32

Judging History

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

  • [2023-11-27 09:08:32]
  • 评测
  • 测评结果:AC
  • 用时:226ms
  • 内存:51780kb
  • [2023-11-27 09:08:30]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
// #define N 
using namespace std;
const int N=3005;
const int f5[5][5]={
{1,1,0,2,2},
{1,3,3,4,2},
{3,1,3,2,4},
{5,0,5,4,4},
{5,5,0,0,0}};
const int f4[4][4]={
{1,1,2,2},
{1,2,3,2},
{4,1,4,3},
{4,4,3,3}};
const int L1[4][4]={
{1,1,0},
{1,2,2},
{2,1,2}};
const int L2[4][4]={
{2,1,1},
{1,2,1},
{2,2,0}};
const int L3[4][4]={
{2,1,2},
{2,2,1},
{0,1,1}};
const int L4[4][4]={
{0,2,2},
{1,2,1},
{1,1,2}};
const int S1[4][4]={
{1,1,0,0},
{1,2,1,2},
{0,0,2,2},
{0,0,0,0}};
const int S2[4][4]={
{0,1,1,0},
{0,2,1,0},
{2,1,0,0},
{2,2,0,0}};
const int M1[4][4]={
{1,1,0,0},
{1,2,0,0},
{2,1,0,0},
{2,2,0,0}};
const int M2[4][4]={
{1,1,2,2},
{1,2,1,2},
{0,0,0,0},
{0,0,0,0}};
int n,ans[N][N];
int t=0;
void pt(int x,int y,const int pp[4][4])
{
        {
            int i=x,j=y;
                for (int x=0;x<4;x++)
                    for (int y=0;y<4;y++)
                    {
                        if (pp[x][y])
                        {
                            ans[i+x][j+y]=t+pp[x][y];
                        }
                    }
            t+=2;
        }
}
void calc(int x,int y,int n)
{
    if (n==5)
    {
        for (int i=0;i<5;i++)
            for (int j=0;j<5;j++)
                ans[i+x][j+y]=t+f5[i][j];
        t+=5;
        return;
    }
    if (n==9)
    {
        int i=x,j=y;
        pt(i+0,j+0,M1);
        pt(i+0,j+2,M2);
        pt(i+0,j+6,L3);
        pt(i+2,j+2,L1);
        pt(i+2,j+5,S1);
        pt(i+4,j+0,S1);
        pt(i+4,j+4,L4);
        pt(i+5,j+7,M1);
        pt(i+6,j+0,L1);
        pt(i+7,j+3,M2);
        return;
    }
    calc(x+2,y+4,n-4);
    pt(x+n-3,y+2,L1);
    pt(x,y+2,S2);
    pt(x,y,L2);
    pt(x+3,y,S1);
    {
        int j=0;
        for (int i=x+5;i+3<x+n;i+=4)
            pt(i,y+j,M1);
    }
    {
        int j=2;
        for (int i=x+6;i+3<x+n-3;i+=4)
            pt(i,y+j,M1);
    }
    {
        for (int i=5;i+3<n;i+=4)
            pt(x+0,y+i,M2);
    }
    {
        for (int i=5;i+3<n;i+=4)
            pt(x+n-2,y+i,M2);
    }
}
void BellaKira()
{
    cin>>n;
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++) ans[i][j]=0;
    t=0;
    if (n<=2)
    {
        cout<<0<<'\n';
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<n;j++)
            {
                cout<<0;
                if (j+1<n) cout<<" ";
            }
            cout<<'\n';
        }
        return;
    }
    if (n==3)
    {
        cout<<2<<'\n';
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<n;j++)
            {
                cout<<L1[i][j];
                if (j+1<n) cout<<" ";
            }
            cout<<'\n';
        }
        return;
    }
    if (n%4==0)
    {
        for (int i=0;i<n;i+=2)
        {
            for (int j=0;j<n;j+=4)
            {
                for (int x=0;x<4;x++)
                    for (int y=0;y<4;y++)
                    {
                        if (M2[x][y])
                            ans[i+x][j+y]=t+M2[x][y];
                    }
                t+=2;
            }
        }
        cout<<t<<'\n';
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<n;j++)
            {
                cout<<ans[i][j];
                if (j+1<n) cout<<" ";
            }
            cout<<'\n';
        }
        return;
    }
    if (n%4==2)
    {
        for (int i=0;i<n;i+=2)
        {
            for (int j=0;j+3<n;j+=4)
            {
                for (int x=0;x<4;x++)
                    for (int y=0;y<4;y++)
                    {
                        if (M2[x][y])
                            ans[i+x][j+y]=t+M2[x][y];
                    }
                t+=2;
            }
        }
        for (int i=0;i+3<n;i+=4)
        {
            for (int j=n-2;j<n;j+=2)
            {
                for (int x=0;x<4;x++)
                    for (int y=0;y<4;y++)
                    {
                        if (M1[x][y])
                            ans[i+x][j+y]=t+M1[x][y];
                    }
                t+=2;
            }
        }
        cout<<t<<'\n';
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<n;j++)
            {
                cout<<ans[i][j];
                if (j+1<n) cout<<" ";
            }
            cout<<'\n';
        }
        return;
    }
    if (n%4==1)
    {
        calc(0,0,n);
        cout<<t<<'\n';
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<n;j++)
            {
                cout<<ans[i][j];
                if (j+1<n) cout<<" ";
            }
            cout<<'\n';
        }
        return;
    }
    if (n%4==3)
    {
        calc(2,2,n-2);
        for (int i=0;i<=0;i+=2)
        {
            for (int j=3;j+3<n;j+=4)
            {
                pt(i,j,M2);
            }
        }
        for (int i=3;i+3<n;i+=4)
        {
            for (int j=0;j<=0;j+=2)
            {
                pt(i,j,M1);
            }
        }
        pt(0,0,L2);
        cout<<t<<'\n';
        for (int i=0;i<n;i++)
        {
            for (int j=0;j<n;j++)
            {
                cout<<ans[i][j];
                if (j+1<n) cout<<" ";
            }
            cout<<'\n';
        }
        return;
    }

}
signed main()
{
    IOS;
    cin.tie(0);
    int T=1;
    cin>>T;
    // cout<<setw(3);

    while (T--)
    {
        BellaKira();
    }
}
/*list:
1.mod 998244353 or 1e9+7 or ???
2.N
3.duipai shuju xingtai duoyidian
...
*/

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

详细

Test #1:

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

input:

2
3
4

output:

2
1 1 0
1 2 2
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: 196ms
memory: 9724kb

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

result:

ok Correct. (246 test cases)

Test #3:

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

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
15252 15251 15251 15007 15007 15008 15008 15009 15009 15010 15010 15011 15011 15012 15012 15013 15013 15014 15014 15015 15015 15016 15016 15017 15017 15018 15018 15019 15019 15020 15020 15021 15021 15022 15022 15023 15023 15024 15024 15025 15025 15026 15026 15027 15027 15028 15028 15029 15029 ...

result:

ok Correct. (64 test cases)

Test #4:

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

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
24180 24179 24179 23871 23871 23872 23872 23873 23873 23874 23874 23875 23875 23876 23876 23877 23877 23878 23878 23879 23879 23880 23880 23881 23881 23882 23882 23883 23883 23884 23884 23885 23885 23886 23886 23887 23887 23888 23888 23889 23889 23890 23890 23891 23891 23892 23892 23893 23893 ...

result:

ok Correct. (45 test cases)

Test #5:

score: 0
Accepted
time: 182ms
memory: 13808kb

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: 213ms
memory: 13672kb

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
38220 38219 38219 37831 37831 37832 37832 37833 37833 37834 37834 37835 37835 37836 37836 37837 37837 37838 37838 37839 37839 37840 37840 37841 37841 37842 37842 37843 37843 37844 37844 37845 37845 37846 37846 37847 37847 37848 37848 37849 37849 37850 37850 37851 37851 37852 37852 37853 37853 ...

result:

ok Correct. (30 test cases)

Test #7:

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

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: 209ms
memory: 50136kb

input:

2
1999
999

output:

999000
999000 998999 998999 997003 997003 997004 997004 997005 997005 997006 997006 997007 997007 997008 997008 997009 997009 997010 997010 997011 997011 997012 997012 997013 997013 997014 997014 997015 997015 997016 997016 997017 997017 997018 997018 997019 997019 997020 997020 997021 997021 997022...

result:

ok Correct. (2 test cases)

Test #9:

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

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: 193ms
memory: 51352kb

input:

2
1997
997

output:

997002
993018 993017 993017 993015 993015 995011 995011 995012 995012 995013 995013 995014 995014 995015 995015 995016 995016 995017 995017 995018 995018 995019 995019 995020 995020 995021 995021 995022 995022 995023 995023 995024 995024 995025 995025 995026 995026 995027 995027 995028 995028 995029...

result:

ok Correct. (2 test cases)

Test #11:

score: 0
Accepted
time: 186ms
memory: 50828kb

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: 209ms
memory: 51116kb

input:

2
1995
995

output:

995006
995006 995005 995005 993013 993013 993014 993014 993015 993015 993016 993016 993017 993017 993018 993018 993019 993019 993020 993020 993021 993021 993022 993022 993023 993023 993024 993024 993025 993025 993026 993026 993027 993027 993028 993028 993029 993029 993030 993030 993031 993031 993032...

result:

ok Correct. (2 test cases)

Test #13:

score: 0
Accepted
time: 226ms
memory: 50704kb

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: 206ms
memory: 51700kb

input:

2
1993
993

output:

993012
989036 989035 989035 989033 989033 991025 991025 991026 991026 991027 991027 991028 991028 991029 991029 991030 991030 991031 991031 991032 991032 991033 991033 991034 991034 991035 991035 991036 991036 991037 991037 991038 991038 991039 991039 991040 991040 991041 991041 991042 991042 991043...

result:

ok Correct. (2 test cases)

Test #15:

score: 0
Accepted
time: 194ms
memory: 50904kb

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: 199ms
memory: 51332kb

input:

2
1991
991

output:

991020
991020 991019 991019 989031 989031 989032 989032 989033 989033 989034 989034 989035 989035 989036 989036 989037 989037 989038 989038 989039 989039 989040 989040 989041 989041 989042 989042 989043 989043 989044 989044 989045 989045 989046 989046 989047 989047 989048 989048 989049 989049 989050...

result:

ok Correct. (2 test cases)

Extra Test:

score: 0
Extra Test Passed