训练补题-杭电多校10
# 杭电多校10补题记录
# 1003: Mine Sweeper (HDU 6879)
看题解
AC代码
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define ull unsigned long long
#define int128 __int128_t
#define Android ios::sync_with_stdio(false), cin.tie(NULL)
#define redirect_input freopen("./input.txt", "r", stdin);
#define redirect_inputlarge freopen("./input_large.txt", "r", stdin);
#define redirect_output freopen("./output.txt", "w", stdout);
#define debug(s, r) std::cerr << #s << ": " << (s) << (r==0?' ':'\n')
#define pii pair<int, int>
#define sqr(x) ((x)*(x))
using namespace std;
char grid[26][26];
void solve(){
int s; cin >> s;
if(s <= 24){
cout << 1 << " " << s + 1 << '\n';
for(int i=0; i<=s; i++) cout << ((i&1)?'X':'.');
cout << '\n';
}else{
int cnt = s / 8, remain = s % 8;
while(remain % 3 != 0){
cnt--;
remain += 8;
}
remain /= 3;
memset(grid, '.', sizeof grid);
for(int i=0; i<25; i++) grid[i][25] = 0;
for(int r=1; cnt > 0; r+=2){
for(int c=1; cnt > 0 && c < 25; c+=2){
cnt--;
grid[r][c] = 'X';
}
}
for(int c=24; remain > 0; c--, remain--){
grid[24][c] = 'X';
}
cout << "25 25\n";
for(int i=0; i<25; i++) cout << grid[i] << '\n';
}
}
signed main(){
Android;
int t; cin >> t;
while(t--){
solve();
}
}
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
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
上次更新: 2021/02/24, 03:37:30