QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#746361#9621. 连方IllusionaryDominance#AC ✓7ms4268kbC++201.8kb2024-11-14 14:23:082024-11-14 14:23:09

Judging History

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

  • [2024-11-14 14:23:09]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:4268kb
  • [2024-11-14 14:23:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T;
    cin >> T;
    while(T--)
    {
        int n;
        cin >> n;
        string s, t;
        cin >> s >> t;
        
        int chk = (s==string(n, '#')) + (t==string(n, '#'));
        if (chk == 1) { cout << "No\n"; continue; }
        cout << "Yes\n";
        
        if(chk == 2)
        {
            for(int i=0; i<7; ++i) cout<<s<<"\n";
            continue;
        }
        
        if(s==string(n, '.') || t==string(n, '.'))
        {
            for(int i=0; i<6; ++i) cout<<s<<"\n";
            cout<<t<<"\n";
            continue;
        }
        
        cout << s << "\n"; string ss="", tt="";
        for(int i=0;i<n;++i) ss+=".#"[s[i]!='#'];
        for(int i=0;i<n;++i) tt+=".#"[t[i]!='#'];
        
        cout << ss << "\n";
        
        int pos1=-1, pos2=-1;
        for(int i=0;i<n;++i)
        {
            if(ss[i]=='.'&&((i>0&&ss[i-1]=='#')||(i+1<n&&ss[i+1]=='#'))) {pos1 = i; break;}
        }
        for(int i=0;i<n;++i)
        {
            if(tt[i]=='.'&&((i>0&&tt[i-1]=='#')||(i+1<n&&tt[i+1]=='#'))) {pos2 = i; break;}
        }
        assert(pos1 != -1 && pos2 != -1);
        
        string sss=string(n, '.'), ttt=string(n, '.'), st = string(n, '.'); sss[pos1] = ttt[pos2] = '#';
        
        cout << sss << "\n";
        
        if(pos1==pos2) st[pos1] = '#';
        else if(abs(pos1-pos2)==1) st[pos1] = '#';
        else 
        {
            for(int i=min(pos1, pos2)+1; i<max(pos1, pos2); ++i) st[i]='#';
        }
        cout << st << "\n";
        
        cout << ttt << "\n";
        
        cout << tt << "\n";
        
        cout << t << "\n";
    }
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 3ms
memory: 4108kb

input:

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

output:

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

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 2ms
memory: 4268kb

input:

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

output:

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

result:

ok Correct.