QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#344495#8217. King's DinnerSolitaryDream#AC ✓1ms3668kbC++172.0kb2024-03-04 17:53:422024-03-04 17:53:43

Judging History

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

  • [2024-03-04 17:53:43]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3668kb
  • [2024-03-04 17:53:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char a[N][N];
inline void Solve(int x, int y, int u, int v) {
    if (x > u) return;
    for (int j = y; j + 3 <= v; j += 2) {
        a[x][j] = a[x + 1][j] = '#';
    }
    for (int i = x; i + 3 <= u; i += 2) {
        a[i][v] = a[i][v - 1] = '#';
    }
    for (int j = v; j - 3 >= y; j -= 2) {
        a[u][j] = a[u - 1][j] = '#';
    }
    for (int i = u; i - 3 >= x; i -= 2) {
        a[i][y] = a[i][y + 1] = '#';
    }
    Solve(x + 3, y + 3, u - 3, v - 3);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int Case;
    cin >> Case;
    while (Case--) {
        int n;
        cin >> n;
        for (int i = 1; i <= n; ++i) {
            fill(a[i] + 1, a[i] + n + 1, '.');
            a[i][n + 1] = 0;
        }
        if (n & 1) {
            for (int i = 1; i + 1 <= n; i += 3) {
                for (int j = 1; j <= n; j += 2) a[i][j] = a[i + 1][j] = '#';
            }
            if (n % 3 == 1) {
                for (int j = 1; j + 1 <= n; j += 3) a[n][j] = a[n][j + 1] = '#';
            }
            if (n % 3 == 0) {
                fill(a[n - 2] + 1, a[n - 2] + n + 1, '.');
                fill(a[n - 1] + 1, a[n - 1] + n + 1, '.');
                for (int i = n - 2; i <= n; i += 2)
                    for (int j = 1; j + 1 <= n; j += 3) 
                        a[i][j] = a[i][j + 1] = '#';
            }
        } else if (n % 6 == 0) {
            Solve(1, 1, n, n);
        } else {
            for (int i = 1; i + 2 <= n; i += 2) {
                a[i][n - 1] = a[i][n] = '#';
            } 
            a[n - 1][n] = a[n][n] = '#';
            for (int i = 1; i + 1 <= n; i += 3) {
                for (int j = 1; j <= n - 2; j += 2) a[i][j] = a[i + 1][j] = '#';
            }
            if (n % 3 == 1) {
                for (int j = 1; j + 3 <= n; j += 3) a[n][j] = a[n][j + 1] = '#';
            }
        }
        for (int i = 1; i <= n; ++i) cout << (a[i] + 1) << '\n';
    }
    return 0;
}

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

詳細信息

Test #1:

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

input:

3
1
2
3

output:

.
.#
.#
##.
...
##.

result:

ok all tests correct (3 test cases)

Test #2:

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

input:

50
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

output:

.
.#
.#
##.
...
##.
#.##
#...
...#
##.#
#.#.#
#.#.#
.....
#.#.#
#.#.#
#.#.##
#.#...
....##
##....
...#.#
##.#.#
#.#.#.#
#.#.#.#
.......
#.#.#.#
#.#.#.#
.......
##.##..
#.#.#.##
#.#.#...
......##
#.#.#...
#.#.#.##
........
#.#.#..#
#.#.#..#
#.#.#.#.#
#.#.#.#.#
.........
#.#.#.#.#
#.#.#.#.#
.........
...

result:

ok all tests correct (50 test cases)

Test #3:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

39
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

output:

#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#
#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#
...................................................
#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#
#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#
...........................................

result:

ok all tests correct (39 test cases)

Test #4:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

11
90
91
92
93
94
95
96
97
98
99
100

output:

#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.##
#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...
........................................................................................##
##.#.#.#.#.#.#.#.#.#.#.#.#....

result:

ok all tests correct (11 test cases)

Test #5:

score: 0
Accepted
time: 1ms
memory: 3660kb

input:

1
100

output:

#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.##
#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...
.....................................................................................................

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed