Task: | Kamen |
Sender: | untokarila |
Submission time: | 2019-07-26 17:18:58 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.02 s | details |
#2 | ACCEPTED | 0.02 s | details |
#3 | ACCEPTED | 0.02 s | details |
#4 | WRONG ANSWER | 0.02 s | details |
#5 | WRONG ANSWER | 0.02 s | details |
#6 | WRONG ANSWER | 0.02 s | details |
#7 | ACCEPTED | 0.08 s | details |
#8 | ACCEPTED | 0.11 s | details |
#9 | RUNTIME ERROR | 0.10 s | details |
#10 | RUNTIME ERROR | 0.11 s | details |
Code
#include <bits/stdc++.h> #define pii pair<int, int> #define F first #define S second using namespace std; char c[31][30001]; int w, h; vector<int> d[31][30001]; pii p[31], r[31][30001]; bool ok(char a, char b){return a=='.' && b=='.';} pii fall(int x, int y){ if(c[x][y+1] == 'X' && y<h) return {x, y}; if(ok(c[x][y+1], c[x][y+1]) && y<h) return {x, y+1}; if(ok(c[x-1][y], c[x-1][y+1]) && y<h && x>1) return {x-1, y+1}; if(ok(c[x+1][y], c[x+1][y+1]) && y<h && x<w) return {x+1, y+1}; return {x, y}; } void drop(int f, bool yee){ int x = p[f].F, y = p[f].S; vector<pair<int, bool> > e; pii prev = r[x][y]; while(1){ if(d[x][y].size()){ for(auto i:d[x][y]) e.push_back({i, 1}); d[x][y].clear(); } pii next = fall(x, y); if(x == next.F && y == next.S) break; for(int i=e.size()-1; e[i].S; i--) e[i].S = 0; prev = r[next.F][next.S]; r[next.F][next.S] = {x, y}; x = next.F; y = next.S; } if(yee){ for(auto i:e){ d[x][y].push_back(i.F); p[i.F] = {x, y}; } return; } else { for(auto i:e){ if(i.S){ d[prev.F][prev.S].push_back(i.F); p[i.F] = prev; } else { d[r[x][y].F][r[x][y].S].push_back(i.F); p[i.F] = r[x][y]; } } } c[x][y] = 'O'; } int main(){ cin >> h >> w; for(int i=1; i<=h; i++){ for(int j=1; j<=w; j++){ cin >> c[j][i]; } } for(int i=1; i<=w; i++){ p[i] = {i, 0}; r[i][0] = {-1e9, 0}; d[i][0].push_back(i); if(p[i].F > 0) drop(i, 1); } int n; cin >> n; for(int i=0; i<n; i++){ int x; cin >> x; drop(x, 0); } for(int i=1; i<=h; i++){ for(int j=1; j<=w; j++){ cout << c[j][i]; } cout << '\n'; } return 0; }
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: WRONG ANSWER
input |
---|
15 15
............... ............... ............... ............... ... |
correct output |
---|
...............
............... ............... ............... ......O........ ... |
user output |
---|
............... ............... ............... ............... ......O........ ... Truncated |
Test 5
Verdict: WRONG ANSWER
input |
---|
30 7
....... ....... ......X ....X.. ... |
correct output |
---|
.......
.OOO..O OOOOO.X OOOOX.. OXXXX.. ... |
user output |
---|
....... ..OO..O .OOOO.X OOOOX.. OXXXX.. ... Truncated |
Test 6
Verdict: WRONG ANSWER
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: RUNTIME ERROR
input |
---|
30000 21
..................... ..................... ..................... ..................... ... |
correct output |
---|
.....................
..................... ..................... ..................... ..................... ... |
user output |
---|
(empty) |
Test 10
Verdict: RUNTIME ERROR
input |
---|
30000 30
................................. |
correct output |
---|
................................. |
user output |
---|
(empty) |