-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1512B.cpp
More file actions
53 lines (51 loc) · 1.44 KB
/
1512B.cpp
File metadata and controls
53 lines (51 loc) · 1.44 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
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--)
{
int n;cin>>n;
char grid[n][n];
pair<int,int> pos1={-1,-1},pos2;
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
cin>>grid[i][j];
if(grid[i][j]=='*') {
if(pos1.first==-1) pos1={i,j};
else pos2={i,j};
}
}
}
if(pos1.first==pos2.first) {
if(pos1.first-1 >=0) {
grid[pos1.first-1][pos1.second] = '*';
grid[pos2.first-1][pos2.second] = '*';
} else {
grid[pos1.first+1][pos1.second] = '*';
grid[pos2.first+1][pos2.second] = '*';
}
}else if(pos1.second==pos2.second) {
if(pos1.second-1 >=0) {
grid[pos1.first][pos1.second-1] = '*';
grid[pos2.first][pos2.second-1] = '*';
} else {
grid[pos1.first][pos1.second+1] = '*';
grid[pos2.first][pos2.second+1] = '*';
}
}else {
grid[pos1.first][pos2.second] = '*';
grid[pos2.first][pos1.second] = '*';
}
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
cout<<grid[i][j];
}
cout<<'\n';
}
}
return 0;
}