QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#790665 | #9621. 连方 | Godwang | AC ✓ | 28ms | 4008kb | C++23 | 3.3kb | 2024-11-28 14:31:26 | 2024-11-28 14:31:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define endl '\n'
#define ll long long
#define pb push_back
const int N=2e5+10;
//////////////////
int tt;
int n;
string s[10];
/////////////////
int judge()
{
int quanshang=1,quanxia=1;
rep(i,1,n)
{
if(s[1][i]=='.')
{
quanshang=0;
break;
}
}
rep(i,1,n)
{
if(s[7][i]=='.')
{
quanxia=0;
break;
}
}
if(quanshang+quanxia==1)
{
return -1;
}
if(quanshang+quanxia==2)
{
return 1;
}
return 0;
}
void solve(int shang,int xia)
{
s[3][shang]='#';
s[5][xia]='#';
if(shang==xia)
{
s[4][shang]='#';
}
else if(shang>xia)
{
if(shang==xia+1)
{
s[4][shang]='#';
}
else
{
rep(i,xia+1,shang-1)
{
s[4][i]='#';
}
}
}
else
{
if(xia==shang+1)
{
s[4][shang]='#';
}
else
{
rep(i,shang+1,xia-1)
{
s[4][i]='#';
}
}
}
}
/////////////////
void init()
{
}
/////////////////
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// freopen("ain.txt","r",stdin);freopen("aout.txt","w",stdout);
cin>>tt;
while (tt--)
{
cin>>n>>s[1]>>s[7];
s[1]=' '+s[1];
s[7]=' '+s[7];
init();
rep(i,2,6)
{
s[i].clear();
s[i].resize(n+3);
}
int teshu=judge();
if(teshu==-1)
{
cout<<"No"<<endl;
continue;
}
cout<<"Yes"<<endl;
if(teshu==1)
{
rep(i,1,7)
{
rep(j,1,n)
{
cout<<"#";
}
cout<<endl;
}
continue;
}
//changgui
int shang,xia;
rep(i,1,n)
{
if(s[1][i]=='#'&&( i-1>0&&s[1][i-1]=='.' || i+1<=n&&s[1][i+1]=='.' ))
{
shang=i;
break;
}
}
rep(i,1,n)
{
if(s[7][i]=='#'&&( i-1>0&&s[7][i-1]=='.' || i+1<=n&&s[7][i+1]=='.' ))
{
xia=i;
break;
}
}
solve(shang,xia);
rep(i,1,n)
{
if(s[1][i]=='.')
{
s[2][i]='#';
}
}
rep(i,1,n)
{
if(s[7][i]=='.')
{
s[6][i]='#';
}
}
rep(i,1,7)
{
rep(j,1,n)
{
if(s[i][j]=='#')
{
cout<<"#";
}
else
{
cout<<".";
}
}
cout<<endl;
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 22ms
memory: 3688kb
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: 28ms
memory: 3900kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 26ms
memory: 3684kb
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: 26ms
memory: 3616kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 24ms
memory: 4008kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 21ms
memory: 4008kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.