QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#63889#5101. Crystal CrosswindNoobie_99TL 2ms3516kbC++142.3kb2022-11-23 16:22:452022-11-23 16:22:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-23 16:22:46]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:3516kb
  • [2022-11-23 16:22:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[" << __LINE__ << ' ' << #x << "]: " << (x) << endl

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int dx, dy, k;
    cin >> dx >> dy >> k;

    pair<int, int> winds[k];
    vector<vector<vector<bool>>> a(dx, vector<vector<bool>>(dy, vector<bool>(k)));
    vector<vector<int>> b(dx, vector<int>(dy));
    for (int i=0; i<k; i++) {
        cin >> winds[i].first >> winds[i].second;
        int c;
        cin >> c;
        for (int j=0; j<c; j++) {
            int x, y;
            cin >> x >> y;
            x--, y--;
            a[x][y][i] = true;
            b[x][y] = 2;
        }
    }

    queue<pair<int, int>> q;
    for (int i=0; i<dx; i++) for (int j=0; j<dy; j++) if (b[i][j]) {
        for (int l=0; l<k; l++) if (!a[i][j][l]) {
            q.emplace(i-winds[l].first, j-winds[l].second);
        }
    }

    while (!q.empty()) {
        auto [i, j] = q.front();
        q.pop();
        if (b[i][j]) continue;
        b[i][j] = 2;

        for (int l=0; l<k; l++) if (!a[i][j][l]) {
            q.emplace(i-winds[l].first, j-winds[l].second);
        }
    }

    for (int j=0; j<dy; j++) {
        for (int i=0; i<dx; i++) cout << (b[i][j] ? '#' : '.');
        cout << '\n';
    }
    cout << '\n';

    for (int i=0; i<dx; i++) for (int j=0; j<dy; j++) if (b[i][j] != 2) {
        b[i][j] = 1;
        bool illegal = false;
        for (int l=0; l<k; l++) {
            int di = i - winds[l].first;
            int dj = j - winds[l].second;
            if (di < 0 || di >= dx || dj < 0 || dj >= dy) illegal = true;

            di = i + winds[l].first;
            dj = j + winds[l].second;
            if (di < 0 || di >= dx || dj < 0 || dj >= dy) continue;
            if (b[di][dj] == 2) illegal = true;
        }
        if (illegal) q.emplace(i, j);
    }

    while (!q.empty()) {
        auto [i, j] = q.front();
        q.pop();
        if (i < 0 || i >= dx || j < 0 || j >= dy || b[i][j] == 2) continue;
        b[i][j] = 0;

        for (int l=0; l<k; l++) if (!a[i][j][l]) {
            q.emplace(i+winds[l].first, j+winds[l].second);
        }
    }

    for (int j=0; j<dy; j++) {
        for (int i=0; i<dx; i++) cout << (b[i][j] ? '#' : '.');
        cout << '\n';
    }
}

详细

Test #1:

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

input:

4 1 1
0 1 2 1 1 3 1

output:

#.#.

#.#.

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 2ms
memory: 3352kb

input:

4 4 2
1 0 4 2 4 2 1 1 3 1 2
-1 0 4 4 3 4 2 3 1 3 4

output:

.##.
####
####
.##.

.##.
####
####
.##.

result:

ok 9 lines

Test #3:

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

input:

8 12 1
-1 -4 10 5 7 2 4 1 5 5 11 1 6 5 3 8 11 5 1 1 4 7 3

output:

....#...
........
....#.#.
##......
#.......
#.......
....#...
........
........
........
....#..#
........

....#...
........
..#####.
##......
#.......
#.......
...##.#.
........
........
........
....#..#
........

result:

ok 25 lines

Test #4:

score: 0
Accepted
time: 2ms
memory: 3212kb

input:

4 4 2
1 0 6 2 1 1 2 1 3 4 3 2 4 4 2
-1 0 6 4 2 2 2 2 3 3 1 3 4 4 3

output:

.##.
##.#
##.#
.##.

.##.
##.#
##.#
.##.

result:

ok 9 lines

Test #5:

score: 0
Accepted
time: 2ms
memory: 3420kb

input:

8 10 1
-6 -6 25 7 3 8 5 8 6 4 5 4 4 3 2 5 3 6 8 5 4 1 9 1 8 7 10 8 4 2 7 3 9 2 4 3 10 4 6 2 10 3 6 8 8 6 10 4 3 6 1 7 9

output:

.....#..
..#.....
...##.#.
.#.##..#
...#...#
..##...#
.#......
#....#.#
#.#...#.
.##..##.

.....#..
.##.....
#..##.#.
##.##..#
...#...#
..##...#
.#......
#....#.#
#.#...#.
.##..##.

result:

ok 21 lines

Test #6:

score: 0
Accepted
time: 2ms
memory: 3396kb

input:

30 25 2
9 -15 229 27 8 13 20 25 20 15 9 7 16 23 4 2 18 20 21 21 24 19 24 2 23 19 18 25 7 11 6 7 5 4 12 15 25 13 1 28 20 9 1 8 8 17 21 3 1 21 20 14 20 1 12 14 16 9 5 19 17 7 24 11 20 15 18 15 11 28 12 9 15 19 20 30 15 4 17 10 13 4 9 20 24 2 24 13 9 20 25 25 24 11 14 20 19 24 12 9 9 3 5 27 14 19 12 12...

output:

..##...##..##....####.....##..
..........###............#....
.......###.##.#.#.....##..##.#
...###.....#..#.....#.#...#.#.
#.##..#.#.#...#.......#..#.#..
#.........#........##..#..#...
...#....#.#....#.##.....#..#..
.......##...##.#..#.#.#..##.#.
...#....#####.#.....##.###....
.#..##.......#...##.#...

result:

ok 51 lines

Test #7:

score: 0
Accepted
time: 2ms
memory: 3256kb

input:

20 20 3
-4 -3 53 18 20 2 10 7 5 17 18 14 6 14 8 13 19 9 18 17 16 20 15 3 20 7 2 8 7 17 6 1 19 20 7 7 6 13 1 18 16 19 14 8 8 19 20 8 20 7 18 2 9 1 4 16 20 2 17 19 19 15 13 20 12 18 10 20 19 8 12 17 13 17 10 18 18 12 19 9 19 20 3 20 4 1 20 20 6 8 5 19 18 17 17 20 16 16 7 19 17 18 14 2 1 19 6 18 8
-12 ...

output:

.#.....#...##.......
......#..#..........
...#........#.#....#
#..........#...#...#
......##.....#......
......##.....#..#.##
.....#.#.......#...#
.......#.#...#...#..
.#.##......#........
.#.....#.#......##..
......#.#.#..#......
.......##......#...#
...#......#####.#...
.......#..#.#.#..##.
..#......

result:

ok 41 lines

Test #8:

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

input:

30 25 3
-20 0 192 26 25 24 20 5 5 22 25 24 25 5 10 27 25 21 8 20 24 20 4 14 17 12 19 17 19 5 19 3 14 16 4 22 23 18 11 21 23 27 7 11 6 3 8 25 4 29 21 28 12 18 21 27 21 23 16 26 13 25 9 15 2 23 24 28 6 26 21 22 21 17 23 19 17 30 12 24 12 26 16 24 5 21 2 25 12 30 24 18 25 30 14 30 7 26 24 25 21 29 17 2...

output:

.#.#...........##..#.##..#.##.
........#.....##...##....##.#.
..##.......#..#.......##.....#
.#...#.........#...#.#..#...#.
...##....#...........#.#..###.
..........#..........#.....###
...#..#....#.#....##....#.##.#
#.#.....#........#..#....#..#.
...##.......#..##....#..#.....
....#.....#......#......

result:

ok 51 lines

Test #9:

score: 0
Accepted
time: 1ms
memory: 3312kb

input:

20 20 1
5 5 29 4 17 16 18 9 4 2 7 1 11 13 9 8 19 13 10 10 1 3 6 8 14 8 6 15 17 13 17 5 10 5 15 1 17 16 8 13 6 11 7 1 18 5 1 19 15 7 17 2 5 12 19 14 11 13 7 1 2

output:

....#....#..........
#...................
....................
........#...........
.#..................
..#....#....#.......
.#........#.#.......
...............#....
............#.......
....#.......#.......
#............#......
....................
....................
.......#............
....#....

result:

ok 41 lines

Test #10:

score: 0
Accepted
time: 1ms
memory: 3312kb

input:

30 25 1
-9 0 55 8 24 2 8 1 4 3 12 6 18 1 12 19 15 26 24 13 20 1 20 18 6 9 14 5 2 13 13 24 11 7 15 11 5 19 11 26 19 14 7 29 7 15 5 19 14 27 7 26 23 12 5 12 14 15 9 12 9 11 24 3 18 3 1 8 14 30 19 25 14 7 12 23 11 7 21 3 25 21 17 23 18 11 12 14 8 4 2 30 7 24 21 28 5 18 12 11 15 18 10 16 18 2 1 30 15 20...

output:

.##...........................
...##.........................
..............................
#.............................
..........##..#............#..
.................#............
.............#............#.##
.#...........#................
...........#..#...............
.................#......

result:

ok 51 lines

Test #11:

score: 0
Accepted
time: 2ms
memory: 3396kb

input:

35 45 2
2 -35 526 24 12 21 34 20 7 22 18 35 39 35 1 2 28 22 13 12 23 17 8 8 32 33 21 23 16 34 41 26 15 9 19 35 41 19 23 19 5 29 8 28 41 10 41 30 22 10 35 3 20 20 16 13 26 1 9 32 32 17 34 11 8 14 31 4 36 31 31 32 33 12 36 12 38 22 28 28 4 17 17 23 17 2 32 33 6 17 9 31 27 12 12 15 34 33 8 7 35 23 9 31...

output:

...##.##...##..#...#.#..#.......#.#
...#...#......#.......##..#..#...#.
.........#........##..#.#.......#..
##.......#...#......#.#...###..#...
.##..#.#......#...##......##.......
...#....#..#.......#.....#...#..#.#
..#...##..##..#....#..###...#.....#
..........#.#...##..#.##....###.###
#.#........#...

result:

ok 91 lines

Test #12:

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

input:

30 55 1
16 20 148 10 2 16 41 9 18 24 37 18 33 13 36 17 21 10 46 4 34 17 46 24 55 17 43 25 47 11 19 5 30 20 22 18 25 12 33 11 52 15 44 18 29 28 35 14 5 23 52 12 38 3 25 26 40 16 38 18 31 18 19 10 54 21 13 6 7 14 32 28 2 25 32 25 31 12 53 12 43 26 16 20 20 5 42 21 32 23 8 29 50 26 24 23 23 29 22 8 15 ...

output:

.#............................
.........#.................#..
.............#..#.............
...............#............#.
.......#.....#................
.........#................#...
.....#........................
.....#...#...#....#...#..#....
...............#..........#...
................#.......

result:

ok 111 lines

Test #13:

score: 0
Accepted
time: 2ms
memory: 3516kb

input:

40 25 2
-26 16 173 8 4 30 18 32 12 13 14 40 1 15 23 37 22 20 20 2 1 13 1 12 11 38 9 15 21 27 13 4 1 40 18 10 24 35 21 28 8 34 3 31 21 13 7 13 2 8 11 30 7 24 15 34 15 14 24 15 18 1 5 37 9 38 17 13 19 6 21 24 1 19 16 36 5 3 21 4 10 19 25 40 14 6 23 33 2 33 16 20 2 22 16 12 6 2 7 4 8 27 7 6 1 28 16 12 ...

output:

.#.#.#.#....#....#...#.#..##.....#....##
.#..........#......#.........#..#.......
...#....#...........#............#...#..
...#...#........#.........#.............
##.......#...........#...#.........#....
..........##......##.#.......#.#.......#
.#...#......#........#....#.##........##
...#.......#....

result:

ok 51 lines

Test #14:

score: -100
Time Limit Exceeded

input:

40 60 8
-11 4 957 32 24 36 13 15 27 40 25 39 45 3 5 35 11 20 9 3 36 36 5 18 19 4 6 40 23 19 11 23 42 5 31 7 2 40 31 29 31 28 39 21 43 10 60 37 49 26 43 39 34 35 44 4 29 30 42 15 18 22 36 40 14 2 60 12 38 4 12 22 2 19 13 17 37 36 45 13 7 35 2 1 14 20 24 16 9 16 11 25 56 30 25 40 8 8 49 12 32 4 25 37 ...

output:


result: