QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742955#9621. 连方LisensAC ✓24ms3828kbC++233.2kb2024-11-13 17:44:512024-11-13 17:44:51

Judging History

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

  • [2024-11-13 17:44:51]
  • 评测
  • 测评结果:AC
  • 用时:24ms
  • 内存:3828kb
  • [2024-11-13 17:44:51]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define ios ios::sync_with_stdio(false);cin.tie(0),cout.tie(0)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

void solve() {
    ll n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    bool signa = true, signb = true;
    for(int i = 0 ; i < n ; i++) {
        if(a[i] == '.') {
            signa = false;  
        }
        if(b[i] == '.') {
            signb = false;
        }
    }
    if(signa && signb) {
        cout << "Yes" << endl;
        for(int i = 0 ; i < 7 ; i++) {
            cout << a << endl;
        }
        return;
    } else if(signa ^ signb) {
        cout << "No" << endl;
        return;
    }

    string ra = a, rb = b;
    for(int i = 0 ; i < n ; i++) {
        if(a[i] == '#') {
            ra[i] = '.';
        } else {
            ra[i] = '#';
        }
        if(b[i] == '#') {
            rb[i] = '.';
        } else {
            rb[i] = '#';
        }
    }
    ll idxa = 0;
    ll idxb = 0;
    cout << "Yes" << endl << a << endl << ra << endl;
    for(int i = 0 ; i < n ; i++) {
        if(i == 0) {
            if(ra[i] == '.' && ra[i + 1] == '#') {
                idxa = i;
                break;
            }
        } else if(i == n - 1) {
            if(ra[i] == '.' && ra[i - 1] == '#') {
                idxa = i;
                break;
            }
        } else {
            if(ra[i] == '.' && (ra[i - 1] == '#' || ra[i + 1] == '#')) {
                idxa = i;
                break;
            }
        }
    }
    for(int i = 0 ; i < n ; i++) {
        if(i == 0) {
            if(rb[i] == '.' && rb[i + 1] == '#') {
                idxb = i;
                break;
            }
        } else if(i == n - 1) {
            if(rb[i] == '.' && rb[i - 1] == '#') {
                idxb = i;
                break;
            }
        } else {
            if(rb[i] == '.' && (rb[i - 1] == '#' || rb[i + 1] == '#')) {
                idxb = i;
                break;
            }
        }
    }
    ll mx = max(idxa, idxb);
    ll mi = min(idxa, idxb);

    for(int i = 0 ; i < n ; i++) {
        if(i == idxa) {
            cout << '#';
        } else {
            cout << '.';
        }
    }
    cout << endl;

    if(abs(mx - mi) <= 1) {
        for(int i = 0 ; i < n ; i++) {
            if(i == mi) {
                cout << '#';
            } else {
                cout << '.';
            }
        }
    } else {
        for(int i = 0 ; i < n ; i++) {
            if(mi < i && i < mx) {
                cout << '#';
            } else {
                cout << '.';
            }
        }
    }
    cout << endl;

    for(int i = 0 ; i < n ; i++) {
        if(i == idxb) {
            cout << '#';
        } else {
            cout << '.';
        }
    }
    cout << endl;
    cout << rb << endl << b << endl;
}

signed main() {
    // ios;
    int _ = 1;
    //cout << fixed << setprecision(2);
    cin >> _;
    while(_--) solve();
    return 0;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 24ms
memory: 3828kb

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 22ms
memory: 3504kb

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.