QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#765765#9621. 连方afeng111#AC ✓17ms4360kbC++203.1kb2024-11-20 15:12:492024-11-20 15:12:50

Judging History

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

  • [2024-11-20 15:12:50]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:4360kb
  • [2024-11-20 15:12:49]
  • 提交

answer

#include <iostream>
#include <map>
#include <set>
#include <array>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <random> //mt19937 mtrand(time(0));
#include <string>
#include <time.h>
#include <vector>
#include <cstring>
#include <iomanip> //fixed<<setprecision(12)<<
#include <utility> //pair模板,std::move()
#include <assert.h>
#include <algorithm>
#include <unordered_map>
#define QAQ 0
#define endl '\n'
#define close                         \
    std::ios::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const db pi = acos(-1);
const db eps = 1e-7;
const int inf = 1e9;
const ll INF = 2e18;
const int N = 1e5 + 7;
const int M = 5e6 + 7;
const int mod = 998244353;
const int base = 131;
using namespace std;
//

char a[10][N];

void solve()
{
    //	freopen("data.in.txt","r",stdin);
    //	freopen("data.out.txt","w",stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= 7; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            a[i][j] = '.';
        }
    }

    int g1 = 0, g2 = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[1][i];
        if (a[1][i] == '.')
        {
            a[2][i] = '#';
            g1 = 1;
        }
        else
            a[2][i] = '.';
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> a[7][i];
        if (a[7][i] == '.')
        {
            a[6][i] = '#';
            g2 = 1;
        }
        else
            a[6][i] = '.';
    }
    if (g1 == 0 && g2 == 0)
    {
        cout << "Yes\n";
        for (int i = 1; i <= 7; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                cout << '#';
            }
            cout << "\n";
        }
        return;
    }
    else if (g1 == 0 || g2 == 0)
    {
        cout << "No\n";
        return;
    }
    int now1 = -1, now2 = -1;
    for (int i = 1; i < n; i++)
    {
        if (a[2][i] != a[2][i + 1])
        {
            if (a[2][i] == '.')
                now1 = i;
            else
                now1 = i + 1;
            break;
        }
    }
    a[3][now1] = '#';
    for (int i = 1; i < n; i++)
    {
        if (a[6][i] != a[6][i + 1])
        {
            if (a[6][i] == '.')
                now2 = i;
            else
                now2 = i + 1;
            break;
        }
    }
    a[5][now2] = '#';
    if (now1 > now2)
        swap(now1, now2);
    if (now1 == now2 || now1 + 1 == now2)
    {
        a[4][now1] = '#';
    }
    else
    {
        for (int i = now1 + 1; i < now2; i++)
        {
            a[4][i] = '#';
        }
    }
    cout << "Yes\n";
    for (int i = 1; i <= 7; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (a[i][j] == '#')
                cout << a[i][j];
            else
                cout << '.';
        }
        cout << '\n';
    }
}

signed main()
{
    close;
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return QAQ;
}

详细

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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: 16ms
memory: 3732kb

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

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: 16ms
memory: 3660kb

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.