Task: | Kamen |
Sender: | henrikaalto |
Submission time: | 2019-07-25 17:17:08 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | ACCEPTED | 0.01 s | details |
#5 | ACCEPTED | 0.01 s | details |
#6 | ACCEPTED | 0.01 s | details |
#7 | TIME LIMIT EXCEEDED | -- | details |
#8 | TIME LIMIT EXCEEDED | -- | details |
#9 | TIME LIMIT EXCEEDED | -- | details |
#10 | TIME LIMIT EXCEEDED | -- | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &m); ~~~~~^~~~~~~~~~~~~~~~ input/code.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &amt); ~~~~~^~~~~~~~~~~~ input/code.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &it); ~~~~~^~~~~~~~~~~
Code
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("arch=sandybridge") #include<stdio.h> #define N 30100 #define M 35 char board[N][M]; int n, m; inline int isfree(int y, int x) { if (y >= n || x >= m || y < 0 || x < 0) return 0; return board[y][x] == '.'; } int min(int a, int b) { return a < b ? a : b; } const int sz = 1 << 15; int puu[M][sz * 2]; void muuta(int ind, int k, int x) { k++; puu[ind][k += sz] = x; for (k/=2;k;k/=2)puu[ind][k]=min(puu[ind][k*2],puu[ind][k*2+1]); } int hae(int ind, int a, int b) { a++;b++; int r = N; for (a+=sz,b+=sz;a<=b;a/=2,b/=2) { if (a & 1) r = min(r, puu[ind][a++]); if (~b& 1) r = min(r, puu[ind][b--]); } return r; } int main() { scanf("%d%d", &n, &m); for (int j = 0; j < m; ++j) { for (int i = 0; i < sz*2;++i)puu[j][i]=n; } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { char &c = board[i][j]; do {c=getchar_unlocked();} while(c!='X'&&c!='.'); if (c == 'X') { muuta(j,i,i); } } } int amt; scanf("%d", &amt); for (int i = 0; i < amt; ++i) { int it; // printf("kivi %d\n", i); scanf("%d", &it); int y = 0; int x = it - 1; for (;;) { y = hae(x,y, n) - 1; // printf("y=%d x=%d\n", y, x); if (y + 1 >= n) break; else if (board[y + 1][x] == 'O') { if (isfree(y + 1, x - 1) && isfree(y, x - 1)) { x--; y++; } else if (isfree(y, x + 1) && isfree(y + 1, x + 1)) { x++; y++; } else break; } else break; } muuta(x,y, y); board[y][x] = 'O'; } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { putchar_unlocked(board[i][j]); } putchar_unlocked('\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: TIME LIMIT EXCEEDED
input |
---|
30000 5
..... ..... ..... ..... ... |
correct output |
---|
.....
..... ..... ..... .O... ... |
user output |
---|
(empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
input |
---|
30000 13
............. ............. ...XX...XX... ............. ... |
correct output |
---|
.............
...OO...OO... ...XX...XX... O............ OO...OO...OO. ... |
user output |
---|
(empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
input |
---|
30000 21
..................... ..................... ..................... ..................... ... |
correct output |
---|
.....................
..................... ..................... ..................... ..................... ... |
user output |
---|
(empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
input |
---|
30000 30
................................. |
correct output |
---|
................................. |
user output |
---|
(empty) |