QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#809974 | #9621. 连方 | Nana7# | AC ✓ | 20ms | 6696kb | C++14 | 1.8kb | 2024-12-11 18:48:08 | 2024-12-11 18:48:09 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#define I inline
using namespace std;
const int N = 100100;
char up[N],dn[N];
int ans[8][N];
int n;
I void out() {
for(int i=1;i<=7;++i) {
for(int j=1;j<=n;++j) {
if(ans[i][j]) putchar('#');
else putchar('.');
} putchar('\n');
}
}
I void solve() {
cin>>n;
scanf("%s",up+1);
scanf("%s",dn+1);
for(int i=1;i<=n+1;++i)
for(int j=1;j<=7;++j) ans[j][i]=0;
for(int i=1;i<=n;++i) {
ans[1][i]=(up[i]=='#');
ans[7][i]=(dn[i]=='#');
}
bool f1=1,f2=1,c1=1,c2=1;
for(int i=1;i<=n;++i) {
if(!ans[1][i]) f1=0;
if(!ans[7][i]) f2=0;
if(ans[1][i]) c1=0;
if(ans[7][i]) c2=0;
}
if(c1&&c2) {
cout<<"Yes"<<endl;
out(); return ;
} else if(c2) {
cout<<"Yes"<<endl;
for(int i=1;i<=n;++i) ans[2][i]=1-ans[1][i];
out();
return ;
} else if(c1) {
cout<<"Yes"<<endl;
for(int i=1;i<=n;++i) ans[6][i]=1-ans[7][i];
out();
return ;
}
if(f1&&f2) {
cout<<"Yes"<<endl;
for(int i=1;i<=7;++i) {
for(int j=1;j<=n;++j) putchar('#');
putchar('\n');
}
return ;
}
if(f1||f2) {
cout<<"No"<<endl;
return ;
}
cout<<"Yes"<<endl;
for(int i=1;i<=n;++i) {
ans[6][i]=1-ans[7][i];
ans[2][i]=1-ans[1][i];
}
int ps1=0,ps2=0;
for(int i=1;i<=n;++i) {
if(ans[2][i]==0&&(ans[2][i-1]==1||ans[2][i+1]==1)) {
ps1=i;
ans[3][ps1]=1;
break;
}
}
for(int i=1;i<=n;++i) {
if(ans[6][i]==0&&(ans[6][i-1]==1||ans[6][i+1]==1)) {
ps2=i;
ans[5][ps2]=1;
break;
}
}
// cout<<ps1<<' '<<ps2<<endl;
if(ps2==ps1||ps2==ps1+1||ps1==ps2+1) {
ans[4][ps1]=1;
} else {
for(int i=max(ps2,ps1)-1;i>=min(ps2,ps1)+1;--i) {
ans[4][i]=1;
}
}
out();
}
int main()
{
int T; cin>>T;
while(T--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5812kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 16ms
memory: 5744kb
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: 16ms
memory: 5924kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 16ms
memory: 5880kb
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: 20ms
memory: 3976kb
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: 6696kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 11ms
memory: 6608kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.