QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#742481#9621. 连方QOJericAC ✓43ms3940kbC++172.0kb2024-11-13 16:41:552024-11-13 16:41:55

Judging History

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

  • [2024-11-13 16:41:55]
  • 评测
  • 测评结果:AC
  • 用时:43ms
  • 内存:3940kb
  • [2024-11-13 16:41:55]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define ii __int128
using namespace std;
int n;

void trans(vector<bool>&a,string &s){
    for(int i=0;i<n;i++)
        a[i]=(s[i]=='#'?1:0);
} 
void inv(vector<bool>&a,vector<bool>&b){
    for(int i=0;i<n;i++)b[i]=!a[i];
    if(a[0]==0 && a[1]==0)b[0]=0;
}

bool find(vector<bool>&a,vector<bool>&b){
    //cout<<"here"<<endl;
    int k;
    for(int i=0;i<n;i++)
        if(a[i]==1){
            if(i==0)k=i+1;
            else k=i-1;
            b[k]=1;
            //cout<<k<<" kkk"<<endl;
            return 1;
        }
    return 0;
}

void com(vector<bool>&a,vector<bool>&b,vector<bool>&c){
    int ai=-1,bi=-1;
    for(int i=0;i<n;i++){
        c[i]=0;
        if(a[i]==1 && ai==-1)ai=i;
        if(b[i]==1 && bi==-1)bi=i;
    }
    //cout<<ai<<":"<<bi<<endl;
    if(ai==bi)c[ai]=1;
    else if(abs(ai-bi)==1)c[ai]=1;
    else{
        for(int i=min(ai,bi)+1;i<max(ai,bi);i++)
            c[i]=1;
    }
}


string detrans(vector<bool>&a){
    string s="";
    for(int i=0;i<n;i++)s+=(a[i]==1?'#':'.');
    return s;
}
int main(){
    int _;cin>>_;
    while(_--){
        cin >> n;
        vector<vector<bool>> ans(7,vector<bool>(n));
        string s;
        cin>>s;
        trans(ans[0],s);
        cin >>s ;
        trans(ans[6],s);
        inv(ans[0],ans[1]);
        inv(ans[6],ans[5]);
        bool p1=find(ans[1],ans[2]);
        bool p2=find(ans[5],ans[4]);
        //cout<<p1<<" "<<p2<<endl;
        if(!p1 && !p2){
            for(int i=0;i<n;i++){
                ans[1][i]=ans[2][i]=ans[3][i]=ans[4][i]=ans[5][i]=1;
            }
        }else if(!p1 || !p2){
            cout<<"No"<<endl;
            continue;
        }else{
            com(ans[2],ans[4],ans[3]);
        }
        cout<<"Yes"<<endl;
        for(int i=0;i<=6;i++){
            cout<<detrans(ans[i])<<endl;
            //for(int j=0;j<n;j++)cout<<ans[i][j]<<" ";cout<<endl;
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3736kb

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 27ms
memory: 3828kb

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: 27ms
memory: 3604kb

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 43ms
memory: 3800kb

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: 3616kb

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 7ms
memory: 3940kb

input:

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

output:

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

result:

ok Correct.