QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770331 | #9621. 连方 | ucup-team3294# | AC ✓ | 19ms | 5460kb | C++23 | 1.8kb | 2024-11-21 21:28:28 | 2024-11-21 21:28:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define x first
#define y second
#define PII pair<int,int>
const int mod=998244353;
void solve() {
int n=7,m;
cin>>m;
vector<vector<char>> a(n+1,vector<char>(m+1,'.'));
int s1=0,s2=0;
for(int j=1; j<=m; j++) cin>>a[1][j],s1+=(a[1][j]=='#');
for(int j=1; j<=m; j++) cin>>a[7][j],s2+=(a[7][j]=='#');
for(int j=1; j<=m; j++) a[2][j]=(a[1][j]=='#'?'.':'#');
for(int j=1; j<=m; j++) a[6][j]=(a[7][j]=='#'?'.':'#');
if(s1==m&&s2==m) {
cout<<"Yes\n";
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
cout<<(char)('#');
}
cout<<"\n";
}
} else if(s1==m||s2==m) {
cout<<"No\n";
} else {
vector<int> l,r;
for(int j=1; j<=m; j++) {
if(a[2][j]=='.') {
if(j!=1) if(a[2][j-1]=='#') l.push_back(j);
if(j!=m) if(a[2][j+1]=='#') l.push_back(j);
}
}
for(int j=1; j<=m; j++) {
if(a[6][j]=='.') {
if(j!=1) if(a[6][j-1]=='#') r.push_back(j);
if(j!=m) if(a[6][j+1]=='#') r.push_back(j);
}
}
int x=l[0],y=r[0];
// cout<<x<<" "<<y<<endl;
if(x==y) {
a[3][x]=a[4][x]=a[5][x]='#';
} else if(x>y) {
if(y+1==x) {
a[3][x]=a[4][y]=a[5][y]='#';
} else {
a[5][y]=a[3][x]='#';
for(int j=y+1; j<=x-1; j++) {
a[4][j]='#';
}
}
} else if(x<y) {
if(x+1==y) {
a[3][x]=a[4][y]=a[5][y]='#';
} else {
a[5][y]=a[3][x]='#';
for(int j=x+1; j<=y-1; j++) {
a[4][j]='#';
}
}
}
cout<<"Yes\n";
for(int i=1; i<=7; i++) {
for(int j=1; j<=m; j++) {
cout<<a[i][j];
}
cout<<"\n";
}
}
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
*/
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
cin>>T;
while(T--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... .#.. .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 19ms
memory: 3880kb
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: 15ms
memory: 3732kb
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: 3632kb
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: 19ms
memory: 3696kb
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: 5408kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 16ms
memory: 5460kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.