CSES - COCI 2006/2007 #3 - Results
Submission details
Task:Tenkici
Sender:henrikaalto
Submission time:2019-07-25 18:15:47 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1--details
#2--details
#3--details
#4--details
#5--details
#6--details
#7--details
#8--details
#9--details
#100.01 sdetails
#110.01 sdetails
#120.01 sdetails
#130.01 sdetails
#140.01 sdetails

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:

input
3
2 1
3 1
2 2

correct output
3
1 U
2 R
3 R

user output
(empty)

Test 2

Verdict:

input
4
3 2
3 1
4 1
4 2

correct output
8
2 U
2 U
3 U
1 U
...

user output
(empty)

Test 3

Verdict:

input
5
5 4
4 2
4 4
2 2
...

correct output
6
5 U
5 U
4 U
2 U
...

user output
(empty)

Test 4

Verdict:

input
6
5 1
5 6
1 4
6 6
...

correct output
7
1 U
1 U
6 U
3 D
...

user output
(empty)

Test 5

Verdict:

input
7
5 3
4 4
5 5
3 5
...

correct output
8
6 D
5 U
3 D
7 U
...

user output
(empty)

Test 6

Verdict:

input
8
8 7
2 2
8 8
2 1
...

correct output
16
4 D
2 D
2 D
5 D
...

user output
(empty)

Test 7

Verdict:

input
9
1 2
2 2
8 8
9 8
...

correct output
24
8 D
8 D
2 D
2 D
...

user output
(empty)

Test 8

Verdict:

input
10
4 2
5 3
7 1
3 2
...

correct output
36
4 U
4 U
1 U
1 U
...

user output
(empty)

Test 9

Verdict:

input
50
1 47
12 29
35 12
6 47
...

correct output
544
34 D
34 D
34 D
34 D
...

user output
(empty)

Test 10

Verdict:

input
100
53 50
31 76
46 54
94 37
...

correct output
1913
40 U
40 U
40 U
40 U
...

user output
(empty)

Test 11

Verdict:

input
250
196 74
148 245
203 19
113 198
...

correct output
2370
185 D
185 D
185 D
185 D
...

user output
(empty)

Test 12

Verdict:

input
350
185 170
222 294
183 181
159 171
...

correct output
25660
235 U
235 U
235 U
235 U
...

user output
(empty)

Test 13

Verdict:

input
465
160 163
177 231
220 111
430 330
...

correct output
48963
400 U
400 U
400 U
400 U
...

user output
(empty)

Test 14

Verdict:

input
500
428 393
30 377
76 52
21 218
...

correct output
10301
195 D
195 D
195 D
195 D
...

user output
(empty)