QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#320114#8217. King's Dinnerucup-team1055#AC ✓1ms3676kbC++201.9kb2024-02-03 13:49:132024-02-03 13:49:14

Judging History

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

  • [2024-02-03 13:49:14]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3676kb
  • [2024-02-03 13:49:13]
  • 提交

answer

#include <bits/stdc++.h>

#define rep(i,s,n) for(int i = int(s); i < int(n); i++)
#define rrep(i,s,n) for(int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;
using ull = unsigned long long;
using ld = long double;

template<class T>
bool chmin(T &a, T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

template<class T>
bool chmax(T &a, T b) {
    if(a >= b) return false;
    a = b;
    return true;
}

using namespace std;

vector<string> table;

void put(int x, int y){
    table[x][y] = '#';
}

void calc_even(int n, int lx, int ly){
    if (n <= 0) return ;
    if (n == 2){
        put(lx,ly);
        put(lx+1,ly);
        return ;
    }
    for (int i = 0; i < n-3; i += 2){
        put(lx,ly+i);
        put(lx+1,ly+i);
        put(lx+i,ly+n-2);
        put(lx+i,ly+n-1);
        put(lx+n-1,ly+n-1-i);
        put(lx+n-2,ly+n-1-i);
        put(lx+n-1-i,ly);
        put(lx+n-1-i,ly+1);
    }
    calc_even(n-6,lx+3,ly+3);
}

void calc_odd(int n, int lx, int ly){
    if (n <= 1) return ;
    if (n == 3){
        put(lx,ly);
        put(lx+1,ly);
        put(lx,ly+2);
        put(lx+1,ly+2);
        return ;
    }
    for (int i = 0; i < n; i += 2){
        put(lx,ly+i);
        put(lx+1,ly+i);
        put(lx+n-1,ly+i);
        put(lx+n-2,ly+i);
    }
    for (int i = 3; i < n-3; i += 2){
        put(lx+i,ly);
        put(lx+i,ly+1);
        put(lx+i,ly+n-1);
        put(lx+i,ly+n-2);
    }
    calc_odd(n-6,lx+3,ly+3);
}

void solve(){
    int n; cin >> n;
    table.resize(n);
    rep(i,0,n) table[i] = string(n,'.');
    (n % 2 == 0 ? calc_even(n,0,0) : calc_odd(n,0,0));
    rep(i,0,n) cout << table[i] << '\n';
    // cout << endl;
}

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

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

详细

Test #1:

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

input:

3
1
2
3

output:

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

result:

ok all tests correct (3 test cases)

Test #2:

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

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

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

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

input:

1
100

output:

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

result:

ok all tests correct (1 test case)

Extra Test:

score: 0
Extra Test Passed