QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#738390#9621. 连方ATRI_qwqAC ✓16ms6896kbC++172.5kb2024-11-12 18:57:092024-11-12 18:57:11

Judging History

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

  • [2024-11-12 18:57:11]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:6896kb
  • [2024-11-12 18:57:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int ans[10][maxn];

void solve()
{
    int n;
    cin >> n;

    string a, b;
    cin >> a >> b;

    for (int i = 1; i <= 7; i++) 
        for (int j = 1; j <= n; j++)
            ans[i][j] = 0;
    
    int flag1 = 0, flag2 = 0;
    for (auto ch : a) 
        if (ch == '.') flag1 = 1;
    for (auto ch : b) 
        if (ch == '.') flag2 = 1;
        
    // cout << flag1 << flag2 << '\n';
    if (flag1 + flag2 == 1) {
        cout << "No\n";
        return;
    }
    if (flag1 + flag2 == 0) {
        cout << "Yes\n";
        for (int i = 1; i <= 7; i++) {
            for (int j = 1; j <= n; j++) {
                cout << '#';
            }
            cout << '\n';
        }
        return;
    }

    cout << "Yes\n";


    for (int i = 1; i <= n; i++) {
        if (a[i - 1] == '#') ans[1][i] = 1;
        else ans[1][i] = 0;
        if (b[i - 1] == '#') ans[7][i] = 1;
        else ans[7][i] = 0;
    }
    
    for (int i = 1; i <= n; i++) {
        ans[2][i] = 1 - ans[1][i];
        ans[6][i] = 1 - ans[7][i];
    }
    int t1, t2;
    
    for (int i = 1; i <= n - 1; i++) {
        if (ans[2][i] == 1 && ans[2][i + 1] == 0) {
            t1 = i + 1;
            ans[3][i + 1] = 1;
            break;
        }
        else if (ans[2][i] == 0 && ans[2][i + 1] == 1) {
            t1 = i;
            ans[3][i] = 1;
            break;
        }
    }
    for (int i = 1; i <= n - 1; i++) {
        if (ans[6][i] == 1 && ans[6][i + 1] == 0) {
            ans[5][i + 1] = 1;
            t2  = i + 1;
            break;
        }
        else if (ans[6][i] == 0 && ans[6][i + 1] == 1) {
            ans[5][i] = 1;
            t2  = i;
            break;
        }
    }

    // cout << t1 << " " << t2 << '\n';
    if (t1 - t2 > 1) {
        for (int i = t2 + 1; i <= t1 - 1; i++) {
            ans[4][i] = 1;
        }
    }

    else if (t2 - t1 > 1) {
        for (int i = t1 + 1; i <= t2 - 1; i++) {
            ans[4][i] = 1;
        }
    }
    else {
        ans[4][t1] = 1;
    }
    for (int i = 1; i <= 7; i++) {
        for (int j = 1; j <= n; j++) {
            if (ans[i][j] == 1) cout << '#';
            else cout << '.';
        }
        cout << '\n';
    }
    return;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    while(t--) 
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 16ms
memory: 6756kb

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.