CSES - COCI 2006/2007 #6 - Results
Submission details
Task:Kamen
Sender:henrikaalto
Submission time:2019-07-27 20:17:16 +0300
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#2ACCEPTED0.01 sdetails
#3ACCEPTED0.01 sdetails
#4ACCEPTED0.01 sdetails
#5ACCEPTED0.01 sdetails
#6ACCEPTED0.01 sdetails
#7ACCEPTED0.05 sdetails
#8ACCEPTED0.07 sdetails
#9ACCEPTED0.09 sdetails
#10ACCEPTED0.12 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

struct pos {
    int y, x;
    pos(int Y, int X)
    {
        y = Y;
        x = X;
    }
};

#define N 30100
#define M 35

char board[N][M];
vector<pos> path[M];
int n, m;

int empty(int y, int x)
{
    return board[y][x] == '.';
}

void gen(int y, int x, vector<pos> &vec)
{
    vec.push_back(pos(y, x));
    if (y == n || board[y + 1][x] == 'X') {
        return ;
    }
    if (empty(y + 1, x)) {
        gen(y + 1, x, vec);
    }
    else {
        if (empty(y, x - 1) && empty(y + 1, x - 1)) {
            gen(y + 1, x - 1, vec);
        }
        else if (empty(y, x + 1) && empty(y + 1, x + 1)) {
            gen(y + 1, x + 1, vec);
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> board[i][j];
        }
    }
    for (int j = 1; j <= m; ++j) {
        gen(1, j, path[j]);
    }
    int amt;
    cin >> amt;
    for (int it = 1; it <= amt; ++it) {
        int x;
        cin >> x;
        #define k path[x].back()
        while (board[k.y][k.x] == 'O') {
            path[x].pop_back();
        }
        pos z = path[x].back();
        path[x].pop_back();
        gen(z.y, z.x, path[x]);
        assert(board[k.y][k.x] == '.');
        board[k.y][k.x] = 'O';
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cout << board[i][j];
        }
        cout << "\n";
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
5 5
.....
.....
..X..
.....
...

correct output
.....
.OO..
OOX..
OO...
OOOO.

user output
.....
.OO..
OOX..
OO...
OOOO.

Test 2

Verdict: ACCEPTED

input
6 20
....................
..........X.X.......
X...XX.............X
...XX..........X....
...

correct output
....................
O...O.....X.X......O
X..OXX.........O...X
...XX..........X....
......OO.O....O...O.
...

user output
....................
O...O.....X.X......O
X..OXX.........O...X
...XX..........X....
......
...
Truncated

Test 3

Verdict: ACCEPTED

input
10 10
..........
..........
.XX....X..
..........
...

correct output
..........
.OO....O..
.XX....X..
..........
.....O...O
...

user output
..........
.OO....O..
.XX....X..
..........
.....O...O
...
Truncated

Test 4

Verdict: ACCEPTED

input
15 15
...............
...............
...............
...............
...

correct output
...............
...............
...............
...............
......O........
...

user output
...............
...............
...............
...............
......O........
...
Truncated

Test 5

Verdict: ACCEPTED

input
30 7
.......
.......
......X
....X..
...

correct output
.......
.OOO..O
OOOOO.X
OOOOX..
OXXXX..
...

user output
.......
.OOO..O
OOOOO.X
OOOOX..
OXXXX..
...
Truncated

Test 6

Verdict: ACCEPTED

input
30 30
.................................

correct output
.................................

user output
..............................
...........O.........O........
...........X.........X.O...O

...
Truncated

Test 7

Verdict: ACCEPTED

input
30000 5
.....
.....
.....
.....
...

correct output
.....
.....
.....
.....
.O...
...

user output
.....
.....
.....
.....
.O...
...
Truncated

Test 8

Verdict: ACCEPTED

input
30000 13
.............
.............
...XX...XX...
.............
...

correct output
.............
...OO...OO...
...XX...XX...
O............
OO...OO...OO.
...

user output
.............
...OO...OO...
...XX...XX...
O............
OO...OO...OO.
...
Truncated

Test 9

Verdict: ACCEPTED

input
30000 21
.....................
.....................
.....................
.....................
...

correct output
.....................
.....................
.....................
.....................
.....................
...

user output
.....................
.....................
.....................
.....................
..
...
Truncated

Test 10

Verdict: ACCEPTED

input
30000 30
.................................

correct output
.................................

user output
..............................
..............................
............................

...
Truncated