-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11520.cpp
More file actions
77 lines (71 loc) · 1.42 KB
/
Copy path11520.cpp
File metadata and controls
77 lines (71 loc) · 1.42 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz(a) int((a).size())
#define sza(a) (int)(sizeof(a)/sizeof((a)[0]))
#define all(c) (c).begin(),(c).end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define clr(x) memset(x,0,sizeof x)
#define ft first
#define sd second
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long ul;
const int MX = 10e5 + 1;
int t, n;
bool safe(int a, int b) {
return a >= 0 and a < n and b >= 0 and b < n;
}
void Solution() {
cin >> t;
rep(tt,1,t+1)
{
cin >> n;
char g[n][n];
rep(i,0,n)
rep(j,0,n)
cin >> g[i][j];
rep(i,0,n)
{
rep(j,0,n)
{
char &cur = g[i][j];
if (cur == '.') {
vector<char> xs;
if (safe(i, j + 1))
xs.push_back(g[i][j + 1]);
if (safe(i, j - 1))
xs.push_back(g[i][j - 1]);
if (safe(i + 1, j))
xs.push_back(g[i + 1][j]);
if (safe(i - 1, j))
xs.push_back(g[i - 1][j]);
string xa = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
rep(z,0,sz(xs))
{
auto it = xa.find(xs[z]);
if (it != string::npos)
xa.erase(it, 1);
}
cur = xa.front();
}
}
}
cout << "Case " << tt << ":\n";
rep(i,0,n)
{
rep(j,0,n)
cout << g[i][j];
cout << endl;
}
}
}
int main() {
FastIO;
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
// freopen("output.in", "w", stdout);
#endif
Solution();
return 0;
}