QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#320398#8217. King's Dinnerucup-team2112#AC ✓1ms3788kbC++204.5kb2024-02-03 16:23:392024-02-03 16:23:40

Judging History

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

  • [2024-02-03 16:23:40]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3788kb
  • [2024-02-03 16:23:39]
  • 提交

answer

// #include <bits/stdc++.h>
 
// bool vis[100][100];
// bool ans[100][100];

// int n;
// int res;

// std::pair<int, int> nxt(int x, int y) {
//     if (y == n) return {x + 1, 1};
//     return {x, y + 1};
// }

// bool check(int x, int y) {
//     for (auto dx : {-1, 0, 1}) {
//         for (auto dy : {-1, 0, 1}) {
//             if (x + dx >= 1 && x + dx <= n && y + dy >= 1 && y + dy <= n) {
//                 if (vis[x + dx][y + dy]) return false;
//             }
//         }
//     }
//     return true;
// }

// void dfs(int x, int y, int cur) {
//     if (x == n && y == n) {
//         if (cur > res) {
//             for (int i = 1; i <= n; i++) {
//                 for (int j = 1; j <= n; j++) {
//                     ans[i][j] = vis[i][j];
//                 }
//             }
//         }
//         res = std::max(res, cur);
//         return;
//     }
//     auto [nx, ny] = nxt(x, y);
//     if (y + 1 <= n && check(x, y) && check(x, y + 1)){
//         vis[x][y] = vis[x][y + 1] = true;
//         dfs(nx, ny, cur + 1);
//         vis[x][y] = vis[x][y + 1] = false;
//     }
//     if (x + 1 <= n && check(x, y) && check(x + 1, y)){
//         vis[x][y] = vis[x + 1][y] = true;
//         dfs(nx, ny, cur + 1);
//         vis[x][y] = vis[x + 1][y] = false;
//     }
//     dfs(nx, ny, cur);
// }

// int main(){
//     std::ios::sync_with_stdio(false);
//     std::cin.tie(nullptr);
//     std::cout.tie(nullptr);
//     for (int i = 8; i <= 9; i += 1) {
//         n = i;
//         res = 0;
//         dfs(1, 1, 0);
//         std::cout << n << " " << res << '\n';
//         for (int i = 1; i <= n; i++) {
//             for (int j = 1; j <= n; j++) {
//                 std::cout << (ans[i][j] ? 'o': '.');
//             }
//             std::cout << '\n';
//         }
//     }
//     return 0;
// }
#include <bits/stdc++.h>

int res[200][200];
int n;

void output(){
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            std::cout << (res[i][j] ? '#': '.');
        }
        std::cout << '\n';
    }
}

void solve(){
    memset(res, 0, sizeof(res));
    std::cin >> n;
    if (n % 6 == 0) {
        for (int i = 1; i + 2 <= n; i += 2) {
            for (int j = 1; j + 4 <= n; j += 3) {
                res[i][j] = res[i][j + 1] = 1;
            }
        }
        for (int i = 1; i + 3 <= n; i += 2) {
            res[n - 1][i] = res[n][i] = 1;
        }
        for (int i = 1; i + 4 <= n; i += 3) {
            res[i][n - 2] = res[i][n] = 1;
            res[i + 1][n - 2] = res[i + 1][n] = 1;
        }
        res[n][n] = res[n][n - 1] = 1;
        res[n - 2][n] = res[n - 2][n - 1] = 1;
    }
    if (n % 6 == 4) {
        for (int i = 1; i + 2 <= n; i += 2) {
            for (int j = 1; j + 3 <= n; j += 3) {
                res[i][j] = res[i][j + 1] = 1;
            }
        }
        for (int i = 1; i + 3 <= n; i += 2) {
            res[n - 1][i] = res[n][i] = 1;
        }
        for (int i = 1; i + 3 <= n; i += 3) {
            res[i][n] = res[i + 1][n] = 1;
        }
        res[n][n] = res[n][n - 1] = 1;
    }
    if (n % 6 == 5) {
        for (int i = 1; i <= n; i += 2) {
            for (int j = 1; j + 1 <= n; j += 3) {
                res[i][j] = res[i][j + 1] = 1;
            }
        }
    }
    if (n % 6 == 2) {
        for (int i = 1; i + 2 <= n; i += 2) {
            for (int j = 1; j + 1 <= n; j += 3) {
                res[i][j] = res[i][j + 1] = 1;
            }
        }
        for (int i = 1; i <= n; i += 2) {
            res[n - 1][i] = res[n][i] = 1;
        }
    }
    if (n % 6 == 1) {
        for (int i = 1; i <= n; i += 2) {
            for (int j = 1; j + 1 <= n; j += 3) {
                res[i][j] = res[i][j + 1] = 1;
            }
        }
        for (int i = 1; i + 1 <= n; i += 3) {
            res[i][n] = res[i + 1][n] = 1;
        }
    }
    if (n % 6 == 3) {
        for (int i = 1; i <= n; i += 2) {
            for (int j = 1; j + 3 <= n; j += 3) {
                res[i][j] = res[i][j + 1] = 1;
            }
        }
        for (int i = 1; i + 1 <= n; i += 3) {
            res[i][n - 2] = res[i][n] = 1;
            res[i + 1][n - 2] = res[i + 1][n] = 1;
        }
    }
    output();
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    int T;
    std::cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3724kb

input:

3
1
2
3

output:

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

result:

ok all tests correct (3 test cases)

Test #2:

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

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

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

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

input:

1
100

output:

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

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed