QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751659#9621. 连方walili#AC ✓17ms4344kbC++203.7kb2024-11-15 20:02:442024-11-15 20:02:45

Judging History

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

  • [2024-11-15 20:02:45]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:4344kb
  • [2024-11-15 20:02:44]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
const ll inf= 1e17;
const ll mod = 998244353;
void oper(ll testcase) {
    ll n;
    cin>>n;
    vector <vector <char>> s(10,vector <char>(n+1, '.'));
    for(ll i=1;i<=n;i++) cin>>s[1][i];
    for(ll i=1;i<=n;i++) cin>>s[7][i];

    char all1='$',all2='$';
    for(int i=1;i<=n;i++){
        if(s[1][i]==s[1][1]){
            if(i==n){
                all1=s[1][i];
            }
            continue;
        }else{
            break;
        }
    }
    for(int i=1;i<=n;i++){
        if(s[7][i]==s[7][1]){
            if(i==n){
                all2=s[7][i];
            }
            continue;
        }else{
            break;
        }
    }
    if(all1!='$'&&all2!='$'){
        cout<<"Yes"<<endl;
        if(all1=='#'&&all2=='#'){
            for(int i=1;i<=7;i++){
                for(int j=1;j<=n;j++){
                    cout<<"#";
                }
                cout<<endl;
            }
            return;
        }
        if(all1=='#'&&all2=='.'){
            for(int j=1;j<=n;j++){
                cout<<'#';
            }
            cout<<endl;
            for(int i=1;i<=6;i++){
                for(int j=1;j<=n;j++){
                    cout<<".";
                }
                cout<<endl;
            }
            return;
        }
        if(all1=='.'&&all2=='#'){
            for(int j=1;j<=n;j++){
                cout<<'.';
            }
            cout<<endl;
            for(int i=1;i<=6;i++){
                for(int j=1;j<=n;j++){
                    cout<<"#";
                }
                cout<<endl;
            }
            return;
        }
        if(all1=='.'&&all2=='.'){
            for(int i=1;i<=7;i++){
                for(int j=1;j<=n;j++){
                    cout<<".";
                }
                cout<<endl;
            }
            return;
        }
    }

    ll dot1 = -1, dot2 = -1, sharp1 = -1, sharp2 = -1;
    for (ll i = 1; i <= n; ++i)
        if (s[1][i] == '.') {
            dot1 = i;
            break;
        }
    for (ll i = 1; i <= n; ++i)
        if (s[7][i] == '.') {
            dot2 = i;
            break;
        }
    for (ll i = 1; i <= n; ++i)
        if (s[1][i] == '#' && (i >= 2 && s[1][i - 1] == '.' || i <= n - 1 && s[1][i + 1] == '.')) {
            sharp1 = i;
            break;
        }
    for (ll i = 1; i <= n; ++i)
        if (s[7][i] == '#' && (i >= 2 && s[7][i - 1] == '.' || i <= n - 1 && s[7][i + 1] == '.')) {
            sharp2 = i;
            break;
        }
    for (ll i = 1; i <= n; ++i) {
        if (sharp1 != -1 && s[1][i] == '.')
            s[2][i] = '#';
        if (sharp2 != -1 && s[7][i] == '.')
            s[6][i] = '#';
    }
    if ((dot1 == -1) != (dot2 == -1)) {
        cout << "No\n";
        return;
    }
    if (dot1 == -1 && dot2 == -1)
        for (ll p = 2; p <= 6; ++p)
            for (ll i = 1; i <= n; ++i)
                s[p][i] = '#';
    else if (sharp1 != -1 && sharp2 != -1) {
        s[3][sharp1] = '#';
        s[5][sharp2] = '#';
        if (sharp1 > sharp2)
            swap(sharp1, sharp2);
        if (sharp1 + 1 >= sharp2)
            s[4][sharp1] = '#';
        else
            for (ll i = sharp1 + 1; i <= sharp2 - 1; ++i)
                s[4][i] = '#';
    }
    cout<<"Yes"<<endl;
    for(ll i=1;i<=7;i++){
        for(ll j=1;j<=n;j++){
            cout<<s[i][j];
        }
        cout<<endl;
    }
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int ttt = 1;
    cin >> ttt;
    for (ll i = 1; i <= ttt; i++) {
        oper(i);
    }
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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

input:

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

output:

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

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 17ms
memory: 3700kb

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: 17ms
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: 4324kb

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.