QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#766981 | #9621. 连方 | MaxDYF# | AC ✓ | 5ms | 1992kb | C++14 | 2.0kb | 2024-11-20 19:30:30 | 2024-11-20 19:30:35 |
Judging History
answer
#include<stdio.h>
#include<string.h>
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int word;
typedef unsigned char byte;
word case_,n;
inline void getans(char bef[],char nxt[],char nnxt[]){
if(bef[0]=='.'){
for(word i=1;i<n;++i)
if(bef[i-1]=='.'&&bef[i]=='#')
nxt[i-1]='#';
}else if(bef[n-1]=='.'){
for(word i=1;i<n;++i)
if(bef[i-1]=='#'&&bef[i]=='.')
nxt[i]='#';
}else{
int pos=n;
for(word i=n;i--;) if(bef[i]=='.'&&bef[i+1]=='#')
if(i==0||bef[i-1]=='#'||(i>=2&&bef[i-2]=='.')) pos=i;
if(pos!=n){
for(word i=1;i<pos;++i)
if(bef[i-1]=='#'&&bef[i]=='.') nxt[i]='#';
for(word i=pos+1;i<n;++i)
if(bef[i-1]=='.'&&bef[i]=='#') nxt[i-1]='#';
}else{
for(word i=1;i<n;++i)
if(bef[i-1]=='.'&&bef[i]=='#') nxt[i-1]='#';
for(word i=0;i<n;++i)
if(bef[i]=='.'){
nxt[i]='#';
nnxt[i]=nnxt[i+1]='.';
return;
}
}
}
}
char s[7][100010];
struct READ{
char c;
inline READ(){c=getchar();}
inline READ& operator>>(char s[]){
while(c!='.'&&c!='#') c=getchar();
for(word i=0;i<n;++i)
s[i]=c,c=getchar();
return s[n]='\0',*this;
}
template<typename type>
inline READ& operator>>(type &num){
while('0'>c||c>'9') c=getchar();
for(num=0;'0'<=c&&c<='9';c=getchar())
num=num*10+(c-'0');
return *this;
}
}cin;
int main(){
for(cin>>case_;case_;--case_){
cin>>n>>s[0]>>s[6];
bool b0=1,b1=1;
for(word i=0;i<n;++i){
if(s[0][i]=='.') b0=0;
if(s[6][i]=='.') b1=0;
}
if(b0&&b1){
puts("Yes");
for(word i=0;i<7;++i) puts(s[0]);
continue;
}
if(b0||b1){
puts("No");
continue;
}
for(word i=0;i<7;++i) s[i][n]='\0';
for(word i=0;i<n;++i){
s[1][i]=s[5][i]='.';
s[3][i]=i&1? '#':'.';
s[2][i]=s[4][i]=i&1? '.':'#';
}
getans(s[0],s[1],s[2]);
getans(s[6],s[5],s[4]);
for(word i=0;i<n;++i)
if(s[3][i]=='.'&&s[2][i]=='.'&&s[4][i]=='.')
s[3][i]='#';
puts("Yes");
for(word i=0;i<7;++i) puts(s[i]);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 1344kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.# #.#. #... .##. Yes ##.#. ..#.# #.#.# .#.#. #.#.# #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... #.#.#.#.#.#.#.#.#.#.#.#.#.# .#.#.#.#.#.#.#.#.#.#.#.#.#. #.#.#.#.#.#.#.#.#.#.#.#.#.# #......#.....#.......#..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 5ms
memory: 1340kb
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: 0ms
memory: 1368kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# .#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#. #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 5ms
memory: 1380kb
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: 5ms
memory: 1380kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...#.. #.#.#. .#.#.# #.#.#. ..#..# ##..#. Yes .#.###### #.#...... #.#.#.#.# .#.#.#.#. #.#.#.#.# .#..#.... #.#..#### Yes ######.########################################## ......#.......................................... #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.# .#.#.#.#.#.#.#.#...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 5ms
memory: 1992kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 0ms
memory: 1960kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.