QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#331542#8217. King's Dinner8BQube#AC ✓1ms3772kbC++202.1kb2024-02-18 14:52:112024-02-18 14:52:11

Judging History

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

  • [2024-02-18 14:52:11]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3772kb
  • [2024-02-18 14:52:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define SZ(a) ((int)a.size())

string ans[105];

void solve(int x, int y, int n) {
    if (n <= 1) return;
    if (n == 2) {
        ans[x][y] = ans[x + 1][y] = '#';
        return;
    }
    if (n % 2 == 0) {
        for (int i = 0; i < n / 2 - 1; ++i) {
            ans[x][y + i * 2] = ans[x + 1][y + i * 2] = '#';
        }
        for (int i = 0; i < n / 2 - 1; ++i) {
            ans[x + i * 2][y + n - 1] = ans[x + i * 2][y + n - 2] = '#';
        }
        for (int i = 0; i < n / 2 - 1; ++i) {
            ans[x + n - 1][y + n - 1 - i * 2] = ans[x + n - 2][y + n - 1 - i * 2] = '#';
        }
        for (int i = 0; i < n / 2 - 1; ++i) {
            ans[x + n - 1 - i * 2][y] = ans[x + n - 1 - i * 2][y + 1] = '#';
        }
        solve(x + 3, y + 3, n - 6);
    }
    else if (n % 3 == 2) {
        for (int i = 0; i < n; i += 3)
            for (int j = 0; j < n; j += 2)
                ans[x + i][y + j] = ans[x + i + 1][y + j] = '#';
    }
    else if (n % 3 == 1) {
        for (int i = 0; i + 1 < n; i += 3)
            ans[x + i][y] = ans[x + i + 1][y] = '#';
        for (int i = 1; i < n; i += 3)
            ans[x + n - 1][y + i] = ans[x + n - 1][y + i + 1] = '#';
        solve(x, y + 2, n - 2);
    }
    else {
        for (int i = 0; i + 3 < n; i += 3)
            ans[x + i][y] = ans[x + i + 1][y] = '#';
        ans[x + n - 3][y] = ans[x + n - 3][y + 1] = '#';
        for (int i = 0; i + 1 < n; i += 3)
            ans[x + n - 1][y + i] = ans[x + n - 1][y + i + 1] = '#';
        solve(x, y + 2, n - 2);
    }
}

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        ans[i] = string(n, '.');
    solve(0, 0, n);
    for (int i = 0; i < n; ++i)
        cout << ans[i] << "\n";
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    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: 0ms
memory: 3692kb

input:

3
1
2
3

output:

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

result:

ok all tests correct (3 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3624kb

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: 0ms
memory: 3772kb

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: 3748kb

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: 0ms
memory: 3624kb

input:

1
100

output:

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

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed