QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#747474#9621. 连方mapleKingAC ✓19ms4068kbC++202.3kb2024-11-14 17:16:402024-11-14 17:16:44

Judging History

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

  • [2024-11-14 17:16:44]
  • 评测
  • 测评结果:AC
  • 用时:19ms
  • 内存:4068kb
  • [2024-11-14 17:16:40]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize(2)

// using namespace std;

using i64 = long long;
using u32 = unsigned int;
using u64 = unsigned long long;

void solve() {
    int n;
    std::cin >> n;
    std::string s1, s2;
    std::cin >> s1 >> s2;
    int f1 = 1, f2 = 1;
    for(int i = 0; i < n; i++){
        if (s1[i] == '.') f1 = 0;
        if (s2[i] == '.') f2 = 0;
    }
    if (f1 && f2){
        std::cout << "Yes\n";
        for(int i = 0; i < 7; i++){
            std::cout << s1 << "\n";
        }
        return;
    }
    if (f1 || f2){
        std::cout << "No\n";
        return;
    }
    f1 = -1, f2 = -1;
    for(int i = 0; i < n - 1; i++){
        if (s1[i] != s1[i + 1]){
            if (s1[i] == '#') f1 = i;
            else f1 = i + 1;
            break;
        }
    }
    for(int i = 0; i < n - 1; i++){
        if (s2[i] != s2[i + 1]){
            if (s2[i] == '#') f2 = i;
            else f2 = i + 1;
            break;
        }
    }
    std::cout << "Yes\n";
    std::cout << s1 << "\n";
    for(int i = 0; i < n; i++){
        if (s1[i] == '#') std::cout << ".";
        else std::cout << "#";
    }
    std::cout << "\n";
    for(int i = 0; i < n; i++){
        if (i == f1){
            std::cout << "#";
        }else{
            std::cout << ".";
        }
    }
    std::cout << "\n";
    for(int i = 0; i < n; i++){
        if ((i == f1 && f1 == f2) || (i > std::min(f1, f2) && i < std::max(f1, f2)) ||
            (i == std::min(f1, f2) && std::max(f1, f2) - i == 1)){
            std::cout << "#";
        }else{
            std::cout <<".";
        }
    }
    std::cout << "\n";
    for(int i = 0; i < n; i++){
        if (i == f2){
            std::cout << "#";
        }else{
            std::cout << ".";
        }
    }
    std::cout << "\n";
    for(int i = 0; i < n; i++){
        if (s2[i] == '#') std::cout << ".";
        else std::cout << "#";
    }
    std::cout << "\n";
    std::cout << s2 << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // std::cout << std::fixed << std::setprecision(10); // 固定输出精度
    int t = 1;
    std::cin >> t;

    while (t--) {
        solve();
    }
    

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.