QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736369#9621. 连方cddAC ✓8ms4628kbC++202.0kb2024-11-12 10:30:262024-11-12 10:30:28

Judging History

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

  • [2024-11-12 10:30:28]
  • 评测
  • 测评结果:AC
  • 用时:8ms
  • 内存:4628kb
  • [2024-11-12 10:30:26]
  • 提交

answer

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

// #define int long long

typedef pair<int, int> pii;
typedef long long LL;
typedef unsigned long long uLL;

const int inf32 = 1e9;
const LL inf64 = 1e18;

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(0);

    int T = 1;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        string a, b;
        cin >> a >> b;
        vector<string> ans(10, string(n, '.'));

        int cnta0 = 0, cnta1 = 0, cntb0 = 0, cntb1 = 0;
        int ffa = 0, ffb = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == '.') ++cnta0;
                else ++cnta1;
            if (b[i] == '.') ++cntb0;
                else ++cntb1;
        }
        if (!cnta0 || !cnta1) ffa = 1;
        if (!cntb0 || !cntb1) ffb = 1;

        if (ffa || ffb) {
            if (ffa && ffb) {
                cout << "YES\n";
                for (int i = 1; i <= 6; i++)
                    cout << a << "\n";
                cout << b << "\n";
            } else {
                cout << "NO\n";
            }
            continue;
        }

        ans[1] = a, ans[7] = b;
        for (int i = 0; i < n; i++) {
            ans[2][i] = ans[1][i] == '.' ? '#' : '.';
            ans[6][i] = ans[7][i] == '.' ? '#' : '.';
        }
        if (ans[2][0] == '#' && ans[2][1] == '#') ans[2][0] = '.';
        if (ans[6][0] == '#' && ans[6][1] == '#') ans[6][0] = '.';

        int fir = 0;
        for (int i = 0; i <= n; i++) {
            if (ans[2][i] == '#') {fir = i; break;}
        }
        for (int i = 1; i < fir; i++) ans[3][i] = '#';
        if (fir <= 1) ans[3][0] = '#';
        
        fir = 0;
        for (int i = 0; i <= n; i++) {
            if (ans[6][i] == '#') {fir = i; break;}
        }
        for (int i = 1; i < fir; i++) ans[5][i] = '#';
        if (fir <= 1) ans[5][0] = '#';
        ans[4][0] = '#';

        cout << "YES\n";
        for (int i = 1; i <= 7; i++)
            cout << ans[i] << "\n";
    }


    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

YES
#..#
.##.
#...
#...
#...
#..#
.##.
YES
##.#.
..#.#
.#...
#....
#....
#.#..
.#.##
NO
YES
.######.######.####.#.#####
#......#......#....#.#.....
#..........................
#..........................
#..........................
#....###....##.#######.....
.####...####..#.......#####
YES
########...

result:

ok Correct.

Test #2:

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

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

input:

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

output:

YES
#######.#######.#########################
.......#.......#.........................
.######..................................
#........................................
.###############.........................
................#...#.......#............
################.###.#######.############
YE...

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 4ms
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: 8ms
memory: 3716kb

input:

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

output:

NO
YES
###...
...###
.##...
#.....
.#....
..##.#
##..#.
YES
.#.######
#.#......
#........
#........
#........
.#.##....
#.#..####
YES
######.##########################################
......#..........................................
.#####...........................................
#..................

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 4ms
memory: 4628kb

input:

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

output:

YES
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.##.#.....

result:

ok Correct.

Test #7:

score: 0
Accepted
time: 0ms
memory: 4540kb

input:

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

output:

YES
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##........

result:

ok Correct.