QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#769266 | #9621. 连方 | YFffffff | AC ✓ | 14ms | 6336kb | C++23 | 1.8kb | 2024-11-21 16:51:38 | 2024-11-21 16:51:39 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10, INF = 1e18, MOD = 1e9 + 7;
typedef pair<int, int> PII;
typedef unsigned long long ull;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
int arr[N], brr[N];
map<int,int> mp;
map<PII,int> mpp;
vector<PII> vi, g[N];
vector<int> ans;
bool st[N];
int n, m, k;
void print(string s){
for(int i = 1; i <= n; i ++) cout << s[i];
cout << "\n";
}
void solve()
{
cin >> n;
string t1, t2, t3, t4, t5, t6, t7;
cin >> t1 >> t7;
if(((int)t1.find('.') != -1) ^ ((int)t7.find('.') != -1)){
cout << "NO\n";
return;
}else if(((int)t1.find('.') == -1) && ((int)t7.find('.') == -1)){
cout << "YES\n";
for(int i = 0; i < 7; i ++) cout << t1 << "\n";
return;
}
for(int i = 0; i <= n + 1; i ++){
if(i == 0 || i == n + 1) t2 += " ";
else t2 += '.';
}
t3 = t4 = t5 = t6 = t2;
for(int i = 0; i < n; i ++){
if(t1[i] == '.') t2[i + 1] = '#';
if(t7[i] == '.') t6[i + 1] = '#';
}
int l = 0, r = 0;
for(int i = 1; i <= n; i ++){
if(t2[i] == '#'){
if(t2[i - 1] =='.'){
t3[i - 1] = '#';
l = i - 1;
break;
}else if(t2[i + 1] == '.'){
t3[i + 1] = '#';
l = i + 1;
break;
}
}
}
for(int i = 1; i <= n; i ++){
if(t6[i] == '#'){
if(t6[i - 1] =='.'){
t5[i - 1] = '#';
r = i - 1;
break;
}else if(t6[i + 1] == '.'){
t5[i + 1] = '#';
r = i + 1;
break;
}
}
}
if(l > r) swap(l, r);
for(int i = l + 1; i < r; i ++){
t4[i] = '#';
}
if(r - l <= 1) t4[l] = '#';
cout << "YES\n"<< t1 << "\n";
print(t2);
print(t3);
print(t4);
print(t5);
print(t6);
cout << t7 << "\n";
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
cin >> T;
while (T --) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5496kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
YES #..# .##. #... #... .#.. #..# .##. YES ##.#. ..#.# .#... .#... .#... #.#.. .#.## NO YES .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### YES ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 13ms
memory: 5748kb
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: 14ms
memory: 5884kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
YES #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ YE...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 13ms
memory: 5644kb
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: 9ms
memory: 5908kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
NO YES ###... ...### ..#... .#.... .#.... ..##.# ##..#. YES .#.###### #.#...... .#....... #........ #........ .#.##.... #.#..#### YES ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 12ms
memory: 6304kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
YES ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 11ms
memory: 6336kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
YES ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.