-
Notifications
You must be signed in to change notification settings - Fork 0
/
11520.cpp
45 lines (43 loc) · 901 Bytes
/
11520.cpp
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
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<cctype>
#include<algorithm>
using namespace std;
const int maxn = 15;
char grid[maxn][maxn];
int n;
int main(){
int t;
cin>>t;
int kase=0;
while(t--){
cin>>n;
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
cin>>grid[i][j];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(grid[i][j]!='.') continue;
for(int k = 'A'; k <= 'Z'; k++){
if(i>0&&grid[i-1][j]==k)continue;
if(j>0&&grid[i][j-1]==k)continue;
if(i<n-1&&grid[i+1][j]==k)continue;
if(j<n-1&&grid[i][j+1]==k)continue;
grid[i][j] = (char)k;
break;
}
}
}
cout<<"Case "<<++kase<<":\n";
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++)
cout<<grid[i][j];
cout<<endl;
}
}
}