QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#739203 | #9621. 连方 | ice__cream | AC ✓ | 11ms | 4192kb | C++20 | 2.5kb | 2024-11-12 21:09:22 | 2024-11-12 21:09:25 |
Judging History
answer
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define ss second
#define ff first
#define pb push_back
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int lowbit(int &x)
{
return x&-x;
}
typedef pair<int,int> PII;
const int N = 1e5 + 10;
void solve()
{
int n;
cin >> n;
string s1, s7;
cin >> s1 >> s7;
int t1 = 0, t7 = 0;
for(int i = 0; i < n; i ++ )
{
if(s1[i] == '.') t1 ++;
if(s7[i] == '.') t7 ++;
}
if(!t1 && !t7)
{
cout << "Yes" << endl;
cout << s1 << endl << s1 << endl << s1 << endl << s1 << endl << s1 << endl << s1 << endl << s1;
return;
}
if(!t1 || !t7)
{
cout << "No";
return;
}
cout << "Yes" << endl;
string s2, s3, s4, s5, s6;
for(int i = 0; i < n; i ++ )
{
if(s1[i] == '.') s2 += '#';
else s2 += '.';
}
bool flag = 0;
for(int i = 0; i < n; i ++ )
{
if(s2[i] == '.' && s2[i + 1] == '#' && !flag)
{
s3 += '#';
flag = true;
}
else s3 += '.';
}
if(!flag)
{
for(int i = 0; i < n; i ++ )
{
if(s2[i] == '.' && s2[i - 1] == '#' && !flag)
{
s3[i] = '#';
break;
}
}
}
for(int i = 0; i < n; i ++ )
{
if(s7[i] == '.') s6 += '#';
else s6 += '.';
}
flag = 0;
for(int i = 0; i < n; i ++ )
{
if(s6[i] == '.' && s6[i + 1] == '#' && !flag)
{
s5 += '#';
flag = true;
}
else s5 += '.';
}
if(!flag)
{
for(int i = 0; i < n; i ++ )
{
if(s6[i] == '.' && s6[i - 1] == '#' && !flag)
{
s5[i] = '#';
break;
}
}
}
int x1 = 0, x2 = 0;
for(int i = 0; i < n; i ++ )
{
if(s5[i] == '#') x1 = i;
if(s3[i] == '#') x2 = i;
}
if(x1 > x2) swap(x1, x2);
for(int i = 0; i < n; i ++ )
{
if(i < x2 && i > x1) s4 += '#';
else s4 += '.';
}
if(x1 == x2) s4[x1] = '#';
else if(x2 - x1 == 1) s4[x2] = '#';
cout << s1 << endl << s2 << endl << s3 << endl << s4 << endl << s5 << endl << s6 << endl << s7;
}
signed main()
{
FAST;
int ice = 1;
cin >> ice;
while(ice -- )
{
solve();
cout << endl;
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.. ..#. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......#.................... .....#..................... ....#...................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 10ms
memory: 3628kb
input:
10000 6 .#..## ..#... 5 #..#. ##... 6 .###.# ...### 17 .####..#######..# ###########.##### 6 ..##.# #.##.# 25 #.##.##############.####. ####################.##.# 9 ##.#..##. ##..##### 6 .###.# ##.### 6 ###..# #.#### 25 #####################.#.# ######.################## 6 .#.### .##..# 6 ..#### #......
output:
Yes .#..## #.##.. .#.... ..#... ..#... ##.### ..#... Yes #..#. .##.# #.... .#... .#... ..### ##... Yes .###.# #...#. ...#.. ...#.. ...#.. ###... ...### Yes .####..#######..# #....##.......##. ....#............ .....#####....... ..........#...... ...........#..... ###########.##### Yes ..##.# ##..#. ...
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 11ms
memory: 3592kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 11ms
memory: 3696kb
input:
10000 6 ..#### .#.... 6 ...#.# #..##. 9 ..####.## ######..# 33 #######################.#####..## ######.######.###########.####### 6 ####.# #..##. 6 ...### ##.### 25 ######.#.#.############## .#########.##########.### 17 ############.#### ###############.# 6 #..#.# #####. 6 .#.### ..#... 49 ########...
output:
Yes ..#### ##.... ..#... ..#... .#.... #.#### .#.... Yes ...#.# ###.#. ...#.. .##... #..... .##..# #..##. Yes ..####.## ##....#.. .....#... .....#... .....#... ......##. ######..# Yes #######################.#####..## .......................#.....##.. ......................#.......... ......########...
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 11ms
memory: 3576kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 7ms
memory: 4192kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 10ms
memory: 4180kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.