QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751841#9621. 连方SilverGodlyAC ✓15ms4604kbC++203.9kb2024-11-15 20:56:492024-11-15 20:56:50

Judging History

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

  • [2024-11-15 20:56:50]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:4604kb
  • [2024-11-15 20:56:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'
#define ll long long

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    int ci=0;
    while(t--){
        int n;
        cin>>n;
        string s1,s2;
        cin>>s1>>s2;
        vector<string>s;
        s.push_back(s1);
        int z1=0,z2=0;
        for(int i=0;i<=n-1;i++){
            if(s1[i]=='.'){
                z1++;
            }
            if(s2[i]=='.'){
                z2++;
            }
        }
        string w1="",w2="";
        for(int i=0;i<=n-1;i++){
            if(s1[i]=='.'){
                w1+='#';
            }
            else {
                w1+='.';
            }
        }
        for(int i=0;i<=n-1;i++){
            if(s2[i]=='.'){
                w2+='#';
            }
            else {
                w2+='.';
            }
        }
        if(z1==0&&z2==0){
            cout<<"Yes"<<endl;
            for(int i=0;i<=6;i++){
                cout<<s1<<endl;
            }
            continue;
        }
        if(s1==s2){
            cout<<"Yes"<<endl;
            cout<<s1<<endl;
            for(int i=0;i<=4;i++){
                cout<<w1<<endl;
            }
            cout<<s2<<endl;
            continue;
        }
        if(z1==n){
            cout<<"Yes"<<endl;
            cout<<s1<<endl;
            for(int i=1;i<=5;i++){
                cout<<w2<<endl;
            }
            cout<<s2<<endl;
            continue;
        }
        if(z2==n){
            cout<<"Yes"<<endl;
            cout<<s1<<endl;
            for(int i=1;i<=5;i++){
                cout<<w1<<endl;
            }
            cout<<s2<<endl;
            continue;
        }
        if(z1==0||z2==0){
            cout<<"No"<<endl;
            continue;
        }
        else {
            int wei1=-1,wei2=-1;
            for(int i=0;i<=n-2;i++){
                if(w1[i]=='#'&&w1[i+1]=='.'){
                    wei1=i+1;
                    break;
                }
            }
            for(int i=n-1;i>=1;i--){
                if(wei1!=-1)break;
                if(w1[i]=='#'&&w1[i-1]=='.'){
                    wei1=i-1;
                    break;
                }
            }
            for(int i=0;i<=n-2;i++){
                if(w2[i]=='#'&&w2[i+1]=='.'){
                    wei2=i+1;
                    break;
                }
            }
            for(int i=n-1;i>=1;i--){
                if(wei2!=-1)break;
                if(w2[i]=='#'&&w2[i-1]=='.'){
                    wei2=i-1;
                    break;
                }
            }
            s.push_back(w1);
            string t1="",t2="";
            for(int i=0;i<=n-1;i++){
                if(i==wei1){
                    t1+='#';
                }
                else t1+='.';
            }
            for(int i=0;i<=n-1;i++){
                if(i==wei2){
                    t2+='#';
                }
                else t2+='.';
            }
            if(abs(wei1-wei2)<=1){
               for(int i=1;i<=2;i++){
                  s.push_back(t1);
               }
               s.push_back(t2);
            }
            else {
                string t3="";
                int l1=min(wei1,wei2),l2=max(wei1,wei2);
                s.push_back(t1);
                for(int i=0;i<=n-1;i++){
                    if(i>=l1+1&&i<=l2-1){
                        t3+='#';
                    }
                    else t3+='.';
                }
                s.push_back(t3);
                s.push_back(t2);
            }
            s.push_back(w2);
            s.push_back(s2);
            cout<<"Yes"<<endl;
            for(int i=0;i<=6;i++){
                cout<<s[i]<<endl;
            }
        }
    }
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 12ms
memory: 3664kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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: 15ms
memory: 3728kb

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

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 8ms
memory: 4604kb

input:

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

output:

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

result:

ok Correct.