QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#778358 | #9621. 连方 | tjf4# | AC ✓ | 19ms | 16088kb | C++20 | 1.9kb | 2024-11-24 14:15:19 | 2024-11-24 14:15:20 |
Judging History
answer
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<char> vc;
const int inf=0x3f;
const int N=2e5+10;
ll n,a[8][N];
string s,t;
void print() {
cout<<"Yes"<<'\n';
for(int i=1;i<=7;i++) {
for(int j=1;j<=n;j++) {
if(a[i][j]==1) cout<<'#';
else cout<<'.';
}
cout<<'\n';
}
}
int main() {
IOS
int T;
cin>>T;
map<char,int> mp;
mp['#']=1;
mp['.']=0;
while(T--) {
cin>>n>>s>>t;
for(int i=0;i<=7;i++) {
for(int j=0;j<=n+1;j++) {
a[i][j]=0;
}
}
for(int i=1;i<=n;i++) {
a[1][i]=mp[s[i-1]];
a[7][i]=mp[t[i-1]];
}
ll c1=0,c7=0;
for(int i=1;i<=n;i++) {
c1+=a[1][i];
c7+=a[7][i];
}
if(c1==n&&c7==n) {
for(int i=2;i<=6;i++) {
for(int j=1;j<=n;j++) {
a[i][j]=1;
}
}
print();
continue;
}
else if(c1==n||c7==n) {
cout<<"No"<<'\n';
}
else {
for(int i=1;i<=n;i++) {
a[2][i]=(a[1][i]^1);
a[6][i]=(a[7][i]^1);
}
//3 4 5
ll idx3,idx5;
for(int i=1;i<=n;i++) {
if(i>1&&a[2][i-1]==0&&a[2][i]==1) {
idx3=i-1;
}
if(i<n&&a[2][i+1]==0&&a[2][i]==1) {
idx3=i+1;
}
}
for(int i=1;i<=n;i++) {
if(i>1&&a[6][i-1]==0&&a[6][i]==1) {
idx5=i-1;
}
if(i<n&&a[6][i+1]==0&&a[6][i]==1) {
idx5=i+1;
}
}
a[3][idx3]=a[5][idx5]=1;
if(idx3==idx5) a[4][idx3]=1;
else if(abs(idx3-idx5)==1) {
a[4][idx3]=1;
}
else {
int mi=min(idx3,idx5)+1;
int mx=max(idx3,idx5)-1;
for(int i=mi;i<=mx;i++) a[4][i]=1;
}
print();
}
}
return 0;
}
//4
//4
//#..#
//.##.
//5
//##.#.
//.#.##
//6
//######
//.####.
//27
//.######.######.####.#.#####
//.####...####..#.......#####
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 15852kb
input:
5 4 #..# .##. 5 ##.#. .#.## 6 ###### .####. 27 .######.######.####.#.##### .####...####..#.......##### 10 ########## ##########
output:
Yes #..# .##. ...# ...# ..#. #..# .##. Yes ##.#. ..#.# ...#. ...#. ...#. #.#.. .#.## No Yes .######.######.####.#.##### #......#......#....#.#..... ......................#.... ......................#.... ......................#.... #....###....##.#######..... .####...####..#.......##### Yes ########...
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 17ms
memory: 13944kb
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: 18ms
memory: 14168kb
input:
10000 41 #######.#######.######################### ################.###.#######.############ 6 ..#..# #..##. 6 #.#... #...#. 6 .#.##. ....## 6 ...#.# ##..#. 33 #####.########################### ###########.##################### 6 .##.## .##.#. 5 ..##. ####. 17 #.###.##########. ####.##.#####.##. 5 ....
output:
Yes #######.#######.######################### .......#.......#......................... ................#........................ .................############............ .............................#........... ................#...#.......#............ ################.###.#######.############ Ye...
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 15ms
memory: 13788kb
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: 14120kb
input:
10000 5 ...#. ##### 6 ###... ##..#. 9 .#.###### #.#..#### 49 ######.########################################## ########.#############.########################## 41 ###########.#######.##################### ##############.########################## 6 ###..# ###.## 49 #################################...
output:
No Yes ###... ...### ..#... ...#.. ....#. ..##.# ##..#. Yes .#.###### #.#...... ...#..... ....#.... .....#... .#.##.... #.#..#### Yes ######.########################################## ......#.......................................... .......#......................................... ........########...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 17ms
memory: 16088kb
input:
2 100000 ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...
output:
Yes ###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 17ms
memory: 15384kb
input:
2 100000 ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...
output:
Yes ##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........
result:
ok Correct.