QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#743382 | #9621. 连方 | BaseAI# | AC ✓ | 7ms | 4456kb | C++23 | 2.6kb | 2024-11-13 19:05:15 | 2024-11-13 19:05:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
int dx[]={6,3,1,4};
int dy[]={6,2,1,5};
string s[8];
void solve()
{
for(int i=1;i<=7;i++)
{
s[i].clear();
}
int n;
cin>>n;
string s1,s2;
cin>>s1>>s2;
bool flag1=0,flag2=0;
for(int i=0;i<n;i++)
{
if(s1[i]!='#')
{
flag1=1;
break;
}
}
for(int i=0;i<n;i++)
{
if(s2[i]!='#')
{
flag2=1;
break;
}
}
if(!flag1&&flag2)
{
cout<<"No"<<Endl;
return;
}
if(flag1&&!flag2)
{
cout<<"No"<<Endl;
return;
}
if(!flag1&&!flag2)
{
cout<<"Yes"<<Endl;
for(int i=1;i<=7;i++)
{
cout<<s1<<Endl;
}
return;
}
cout<<"Yes"<<Endl;
s[1]=s1;
s[7]=s2;
s[2]=s1;
s[6]=s2;
for(int i=0;i<n;i++)
{
if(s[2][i]=='.')
{
s[2][i]='#';
}
else
{
s[2][i]='.';
}
if(s[6][i]=='.')
{
s[6][i]='#';
}
else
{
s[6][i]='.';
}
}
int now1=0,now2=0;
for(int i=0;i<n-1;i++)
{
if(s1[i]=='#'&&s1[i+1]=='.')
{
now1=i;
break;
}
if(s1[i]=='.'&&s1[i+1]=='#')
{
now1=i+1;
break;
}
}
for(int i=0;i<n-1;i++)
{
if(s2[i]=='#'&&s2[i+1]=='.')
{
now2=i;
break;
}
if(s2[i]=='.'&&s2[i+1]=='#')
{
now2=i+1;
break;
}
}
for(int i=0;i<n;i++)
{
if(i!=now1)
{
s[3]+='.';
}
else
{
s[3]+='#';
}
}
for(int i=0;i<n;i++)
{
if(i!=now2)
{
s[5]+='.';
}
else
{
s[5]+='#';
}
}
for(int i=0;i<n;i++)
{
s[4]+='.';
}
// cout<<now1<<" "<<now2<<Endl;
if(now1==now2||abs(now1-now2)==1)
{
s[4][now1]='#';
}
else
{
if(now1>now2)swap(now1,now2);
for(int i=now1+1;i<=now2-1;i++)
{
s[4][i]='#';
}
}
for(int i=1;i<=7;i++)
{
cout<<s[i]<<Endl;
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int _=1;
cin>>_;
while(_--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. #... #... .#.. #..# .##. Yes ##.#. ..#.# .#... .#... .#... #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... .#......................... .#......................... .#......................... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 7ms
memory: 3632kb
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: 7ms
memory: 3640kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ......#.................................. .......########.......................... ...............#......................... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 3ms
memory: 3628kb
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: 3ms
memory: 3872kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ..#... .#.... ..##.# ##..#. Yes .#.###### #.#...... .#....... .#....... #........ .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .....#........................................... ......#............
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 0ms
memory: 4456kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 3ms
memory: 4392kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.