QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741694#9621. 连方lzx2017#AC ✓20ms3744kbC++201.6kb2024-11-13 15:01:332024-11-13 15:01:33

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 15:01:33]
  • 评测
  • 测评结果:AC
  • 用时:20ms
  • 内存:3744kb
  • [2024-11-13 15:01:33]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int i,j,n,m,k,l,t,x,y;
string ss,tt;
int pd(string s)
{
    for(int i=0;i<n;i++)
        if(s[i]=='.') return 0;
    return 1;
}
void solve()
{
    cin>>n>>ss>>tt;
    x=pd(ss);y=pd(tt);
    if(x!=y){
        cout<<"No\n";
        return;
    }
    if(x==y&&x==1){
        cout<<"Yes\n";
        for(int i=1;i<=7;i++)
        {
            for(int j=1;j<=n;j++) cout<<"#";
            cout<<"\n";
        }
        return;
    }
    for(int i=2;i<=n;i++) if(i-2>=0&&ss[i-2]=='.'&&ss[i-1]=='#'){
        x=i;break;
    } else if(ss[i-1]=='.'&&ss[i-2]=='#'){
        x=i-1;break;
    }
    for(int i=2;i<=n;i++) if(tt[i-1]=='#'&&tt[i-2]=='.'){
        y=i;break;
    } else if(tt[i-1]=='.'&&tt[i-2]=='#'){
        y=i-1;
        break;
    }
    cout<<"Yes\n";
    cout<<ss<<"\n";
    for(int i=1;i<=n;i++) if(ss[i-1]=='.') cout<<"#";else cout<<".";
    cout<<"\n";
    for(int j=1;j<=n;j++) if(j==x) cout<<"#";else cout<<".";
    cout<<"\n";

    if(abs(x-y)<=1){
        for(int j=1;j<=n;j++) if(j==x) cout<<"#";else cout<<".";
        cout<<"\n";
    } else {
        for(int j=1;j<=n;j++) if(j>=min(x,y)+1&&j<=max(x,y)-1) cout<<"#";else cout<<".";
        cout<<"\n";
    }
    for(int j=1;j<=n;j++) if(j==y) cout<<"#";else cout<<".";
    cout<<"\n";
    for(int j=1;j<=n;j++) if(tt[j-1]=='.') cout<<"#";else cout<<".";
    cout<<"\n";
    cout<<tt<<"\n";
}
signed main()
{
   // freopen("1.in","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>t;
    while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3472kb

input:

5
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
10
##########
##########

output:

Yes
#..#
.##.
#...
#...
.#..
#..#
.##.
Yes
##.#.
..#.#
.#...
.#...
.#...
#.#..
.#.##
No
Yes
.######.######.####.#.#####
#......#......#....#.#.....
.#.........................
.#.........................
.#.........................
#....###....##.#######.....
.####...####..#.......#####
Yes
########...

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 15ms
memory: 3696kb

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: 16ms
memory: 3568kb

input:

10000
41
#######.#######.#########################
################.###.#######.############
6
..#..#
#..##.
6
#.#...
#...#.
6
.#.##.
....##
6
...#.#
##..#.
33
#####.###########################
###########.#####################
6
.##.##
.##.#.
5
..##.
####.
17
#.###.##########.
####.##.#####.##.
5
....

output:

Yes
#######.#######.#########################
.......#.......#.........................
......#..................................
.......########..........................
...............#.........................
................#...#.......#............
################.###.#######.############
Ye...

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 19ms
memory: 3620kb

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: 20ms
memory: 3540kb

input:

10000
5
...#.
#####
6
###...
##..#.
9
.#.######
#.#..####
49
######.##########################################
########.#############.##########################
41
###########.#######.#####################
##############.##########################
6
###..#
###.##
49
#################################...

output:

No
Yes
###...
...###
..#...
..#...
.#....
..##.#
##..#.
Yes
.#.######
#.#......
.#.......
.#.......
#........
.#.##....
#.#..####
Yes
######.##########################################
......#..........................................
.....#...........................................
......#............

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 18ms
memory: 3744kb

input:

2
100000
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...

output:

Yes
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 14ms
memory: 3668kb

input:

2
100000
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...

output:

Yes
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........

result:

ok Correct.