QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#758156 | #9621. 连方 | KnownError_# | AC ✓ | 15ms | 3720kb | C++14 | 2.3kb | 2024-11-17 16:14:19 | 2024-11-17 16:14:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ui = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,l,r) for(int i=(l);i>=(r);--i)
#define repn(i,n) for(int i=0;i<(n);++i)
#define sizc(x) ((int)(x).size())
#define allc(x) (x).begin(),(x).end()
#define fir first
#define sec second
constexpr int N = 1e5+5;
int n;
char s[N],t[N];
void solve(){
cin>>n;
rep(i,0,n+1)s[i]=t[i]=0;
rep(i,1,n)cin>>s[i];
rep(i,1,n)cin>>t[i];
if(count(s+1,s+n+1,'#')==0){
cout<<"Yes\n";
rep(i,1,5){
rep(j,1,n)cout<<".";
cout<<'\n';
}
rep(i,1,n)cout.put(t[i]^'.'^'#');cout<<'\n';
rep(i,1,n)cout.put(t[i]);cout<<'\n';
return;
}
if(count(t+1,t+n+1,'#')==0){
cout<<"Yes\n";
rep(i,1,n)cout.put(s[i]);cout<<'\n';
rep(i,1,n)cout.put(s[i]^'.'^'#');cout<<'\n';
rep(i,1,5){
rep(j,1,n)cout<<".";
cout<<'\n';
}
return;
}
bool f1=count(s+1,s+n+1,'#')==n;
bool f2=count(t+1,t+n+1,'#')==n;
if(f1&&f2){
cout<<"Yes\n";
rep(_,1,7){
rep(i,1,n)cout<<'#';
cout<<'\n';
}
return;
}
if(f1||f2){cout<<"No\n";return;}
cout<<"Yes\n";
rep(i,1,n)cout.put(s[i]);cout<<'\n';
rep(i,1,n)cout.put(s[i]^'.'^'#');cout<<'\n';
int p,q;
rep(i,1,n)if(s[i]=='#'&&(s[i-1]=='.'||s[i+1]=='.'))p=i;
rep(i,1,n)if(t[i]=='#'&&(t[i-1]=='.'||t[i+1]=='.'))q=i;
if(abs(p-q)<=1){
rep(i,1,2){
rep(j,1,n)cout<<(j==p?'#':'.');
cout<<'\n';
}
rep(j,1,n)cout<<(j==q?'#':'.');
cout<<'\n';
}
else{
rep(j,1,n)cout<<(j==p?'#':'.');
cout<<'\n';
int pp=min(p,q),qq=max(p,q);
rep(j,1,n)cout<<(pp<j&&j<qq?'#':'.');
cout<<'\n';
rep(j,1,n)cout<<(j==q?'#':'.');
cout<<'\n';
}
rep(i,1,n)cout.put(t[i]^'.'^'#');cout<<'\n';
rep(i,1,n)cout.put(t[i]);cout<<'\n';
}
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;cin>>T;
while(T--)solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# ...# ..#. #..# .##. Yes ##.#. ..#.# ...#. ...#. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......................#.... ......................#.... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 14ms
memory: 3640kb
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: 3632kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ................#........................ .................############............ .............................#........... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 14ms
memory: 3624kb
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: 15ms
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: 10ms
memory: 3720kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 14ms
memory: 3720kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.