QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#243147#7740. Puzzle: Question Markbrothernumb2002WA 267ms5972kbC++143.6kb2023-11-07 21:30:242023-11-07 21:30:25

Judging History

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

  • [2023-11-07 21:30:25]
  • 评测
  • 测评结果:WA
  • 用时:267ms
  • 内存:5972kb
  • [2023-11-07 21:30:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll read() {
    ll x=0, f=1; char ch=' ';
    while(!isdigit(ch)) { ch=getchar(); if(ch=='-') f=-1; }
    while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch-48), ch=getchar();
    return x*f;
}
int n, tot, a[1005][1005];
void prin24(int i, int j) {
    tot++;
    a[i][j]=a[i][j+1]=a[i+1][j]=a[i+1][j+2]=tot;
    tot++;
    a[i][j+2]=a[i][j+3]=a[i+1][j+3]=a[i+1][j+1]=tot;
}
void prin42(int i, int j) {
    tot++;
    a[i][j]=a[i][j+1]=a[i+1][j]=a[i+2][j+1]=tot;
    tot++;
    a[i+2][j]=a[i+3][j]=a[i+3][j+1]=a[i+1][j+1]=tot;
}
void prin33(int i, int j) {
    tot++;
    a[i][j+1]=a[i][j+2]=a[i+1][j+2]=a[i+2][j+1]=tot;
    tot++;
    a[i+1][j]=a[i+1][j+1]=a[i+2][j]=a[i+2][j+2]=tot;
}
void prin2(int i, int j) {
    tot++;
    a[i][j]=a[i][j+1]=a[i+1][j]=a[i+1][j+2]=tot;
    tot++;
    a[i+1][j+1]=a[i+1][j+3]=a[i+2][j+2]=a[i+2][j+3]=tot;
}
void prin99(int i, int j) {
    prin24(i, j); prin42(i, j+7);
    prin42(i+5, j), prin24(i+7, j+5);
    prin33(i+4, j+6);
    tot++; a[i+0][j+4]=a[i+0][j+5]=a[i+1][j+4]=a[i+1][j+6]=tot;
    tot++; a[i+0][j+6]=a[i+1][j+5]=a[i+2][j+5]=a[i+2][j+6]=tot;
    tot++; a[i+2][j+0]=a[i+3][j+1]=a[i+3][j+2]=a[i+2][j+2]=tot;
    tot++; a[i+2][j+1]=a[i+3][j+0]=a[i+4][j+0]=a[i+4][j+1]=tot;
    prin2(i+2, j+3); prin2(i+4, j+2);
    tot++; a[i+6][j+2]=a[i+6][j+3]=a[i+7][j+2]=a[i+8][j+3]=tot;
    tot++; a[i+7][j+3]=a[i+7][j+4]=a[i+8][j+2]=a[i+8][j+4]=tot;
}
void prin(int i, int j, int x) {
    if(x==9) {
        prin99(i, j);
        return;
    }
    prin(i+2, j, x-4);
    for(int tmp=j;tmp<j+x-5;tmp+=4) prin24(i, tmp), prin24(i+x-2, tmp);
    tot++; a[i][j+x-5]=a[i][j+x-4]=a[i+1][j+x-5]=a[i+2][j+x-4]=tot;
    tot++; a[i+1][j+x-4]=a[i+2][j+x-3]=a[i+3][j+x-4]=a[i+3][j+x-3]=tot;
    for(int tmp=i+3;tmp<i+x-6;tmp+=4) prin42(tmp, j+x-2), prin42(tmp+1, j+x-4);
    tot++; a[i][j+x-3]=a[i][j+x-2]=a[i+1][j+x-3]=a[i+1][j+x-1]=tot;
    tot++; a[i][j+x-1]=a[i+1][j+x-2]=a[i+2][j+x-2]=a[i+2][j+x-1]=tot;
    prin33(i+x-3, j+x-5);
    prin42(i+x-4, j+x-2);
    tot++; a[i+x-5][j+x-4]=a[i+x-4][j+x-4]=a[i+x-4][j+x-3]=a[i+x-5][j+x-2]=tot;
    tot++; a[i+x-5][j+x-3]=a[i+x-5][j+x-1]=a[i+x-6][j+x-2]=a[i+x-6][j+x-1]=tot;
}
void solve() {
    tot=0;
    n=read();
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            a[i][j]=0;
        }
    }
    if(n<=2);
    else if(n==3) {
        prin33(0, 0);
    }
    else if(n==5) {
        prin33(0, 0);
        prin42(0, 3);
        tot++;
        a[3][0]=a[3][1]=a[4][0]=a[4][2]=tot;
    }
    else if(n==7) {
        prin33(0, 0);
        prin42(0, 3);
        prin42(0, 5);
        prin24(5, 0);
        prin33(4, 4);
        tot++;
        a[3][0]=a[3][1]=a[4][0]=a[4][2]=tot;
    }
    else if(n%4==0) {
        for(int i=0;i<n/2;i++) {
            for(int j=0;j<n/4;j++) {
                prin24(i*2, j*4);
            }
        }
    }
    else if(n%4==2) {
        for(int i=0;i<n/2;i++) {
            for(int j=0;j<n/4;j++) {
                prin24(i*2, j*4);
            }
        }
        for(int i=0;i<n/4;i++) {
            prin42(i*4, n-2);
        }
    }
    else if(n%4==1) {
        prin(0, 0, n);
    }
    else if(n%4==3) {
        prin(0, 0, n-2);
        prin42(0, n-2); prin42(4, n-2);
        prin24(n-2, 0); prin24(n-2, 4);
        prin33(n-3, n-3);
    }
    printf("%d\n", tot);
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            printf("%d", a[i][j]);
            if(j!=n-1) printf(" ");
        }
        puts("");
    }
}
int main() {
    int t=read();
    while(t--) solve();
}

詳細信息

Test #1:

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

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: -100
Wrong Answer
time: 267ms
memory: 5972kb

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

result:

wrong answer Jury has better answer. Participant 52, jury 56 (test case 15)