QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#743588#9621. 连方Nuyoah#AC ✓19ms4104kbC++202.7kb2024-11-13 19:34:482024-11-13 19:34:49

Judging History

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

  • [2024-11-13 19:34:49]
  • 评测
  • 测评结果:AC
  • 用时:19ms
  • 内存:4104kb
  • [2024-11-13 19:34:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ull unsigned long long
#define PII pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
const int N=2e5+10,mod=998244353,P=131;

void solve()
{
    int n;
    cin >> n;
    vector<vector<char>> s(8 , vector<char> (n + 1 , '.'));
    for(int i = 1 ; i <= n ; i ++ ) cin >> s[1][i];
    for(int i = 1 ; i <= n ; i ++ ) cin >> s[7][i];
    int cnt1 = 0 , cnt2 = 0;
    for(int i = 1 ; i <= n ; i ++ ) {
        if(s[1][i] == '#') ++ cnt1;
        if(s[7][i] == '#') ++ cnt2;
    }
    if(cnt1 == n && cnt2 != n || cnt1 != n && cnt2 == n) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
    if(cnt1 == n && cnt2 == n || cnt1 == 0 && cnt2 == 0) {
        for(int i = 2 ; i <= 6 ; i ++ ) {
            for(int j = 1 ; j <= n ; j ++ ) s[i][j] = '#';
        }
        for(int i = 1 ; i <= 7 ; i ++ ) {
            for(int j = 1 ; j <= n ; j ++ ) cout << s[i][j];
            cout << '\n';
        }
        return;
    }
    if(cnt1 == 0) {
        for(int i = 1 ; i <= n ; i ++ ) {
            if(s[7][i] == '.') s[6][i] = '#';
        }
        for(int i = 1 ; i <= 7 ; i ++ ) {
            for(int j = 1 ; j <= n ; j ++ ) cout << s[i][j];
            cout << '\n';
        }
        return;
    }
    if(cnt2 == 0) {
        for(int i = 1 ; i <= n ; i ++ ) {
            if(s[1][i] == '.') s[2][i] = '#';
        }
        for(int i = 1 ; i <= 7 ; i ++ ) {
            for(int j = 1 ; j <= n ; j ++ ) cout << s[i][j];
            cout << '\n';
        }
        return;
    }
    for(int i = 1 ; i <= n ; i ++ ) {
        if(s[1][i] == '.') s[2][i] = '#';
    }
    for(int i = 1 ; i <= n ; i ++ ) {
        if(s[7][i] == '.') s[6][i] = '#';
    }
    int p = 0 , q = 0;
    for(int i = 1 ; i <= n ; i ++ ) {
        if(s[2][i] == '.' && (i - 1 >= 1 && s[2][i - 1] == '#' || i + 1 <= n && s[2][i + 1] == '#')) p = i;
    }
    for(int i = 1 ; i <= n ; i ++ ) {
        if(s[6][i] == '.' && (i - 1 >= 1 && s[6][i - 1] == '#' || i + 1 <= n && s[6][i + 1] == '#')) q = i;
    }
    if(p == q) {
        s[3][p] = s[4][p] = s[5][p] = '#';
    }
    else if(abs(p - q) == 1) {
        s[3][p] = s[4][p] = s[5][q] = '#';
    }
    else {
        s[3][p] = s[5][q] = '#';
        for(int i = min(p , q) + 1 ; i < max(p , q) ; i ++ ) s[4][i] = '#';
    }
    for(int i = 1 ; i <= 7 ; i ++ ) {
        for(int j = 1 ; j <= n ; j ++ ) cout << s[i][j];
        cout << '\n';
    }

}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    cin>>T;
    while (T--)
        solve();
    return 0;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

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

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

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.