Submission #101416

# Submission time Handle Problem Language Result Execution time Memory
101416 2019-03-19T01:24:32 Z SomeoneUnknown Tracks in the Snow (BOI13_tracks) C++14
80.3125 / 100
2000 ms 213316 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ii mii(int b, int c){
    return make_pair(b,c);
}

iii miii(int a, int b, int c){
    return make_pair(a, mii(b,c));
}

int main(){
    //ios_base::sync_with_stdio(false);
    int r, c;
    //cin >> r >> c;
    scanf("%d %d", &r, &c);
    //string m[r];
    char m[r][c+2];
    for(int i = 0; i < r; i++){
        //cin >> m[i];
        //cout << "read";
        scanf("%s", &m[i]);
    }
    priority_queue<iii> vable;
    vable.push(miii(-1, 0, 0));
    vable.push(miii(-1, r-1, c-1));
    int most = 0;
    while(!vable.empty()){
        iii ving = vable.top();
        vable.pop();
        int y = ving.second.first;
        int x = ving.second.second;
        if(m[y][x] == '.') continue;
        int a = ving.first;
        most = max(most, -a);
        if(y != r-1){
            vable.push(miii(a-(m[y][x]!=m[y+1][x]), y+1, x));
        }
        if(x != c-1){
            vable.push(miii(a-(m[y][x]!=m[y][x+1]), y, x+1));
        }
        if(y != 0){
            vable.push(miii(a-(m[y][x]!=m[y-1][x]), y-1, x));
        }
        if(x != 0){
            vable.push(miii(a-(m[y][x]!=m[y][x-1]), y, x-1));
        }
        m[y][x] = '.';
    }
    cout << most;//*/
}
/*
5 8
FFRF....
.FRRR...
.FFFFF..
..RRRFFR
.....FFF
*/

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:25:26: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[(c + 2)]' [-Wformat=]
         scanf("%s", &m[i]);
                     ~~~~~^
tracks.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &r, &c);
     ~~~~~^~~~~~~~~~~~~~~~~
tracks.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%s", &m[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 175 ms 1660 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 128 ms 3948 KB Output is correct
5 Correct 14 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 460 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 22 ms 512 KB Output is correct
11 Correct 31 ms 1276 KB Output is correct
12 Correct 59 ms 1044 KB Output is correct
13 Correct 14 ms 640 KB Output is correct
14 Correct 17 ms 512 KB Output is correct
15 Correct 131 ms 1464 KB Output is correct
16 Correct 192 ms 1660 KB Output is correct
17 Correct 82 ms 1088 KB Output is correct
18 Correct 143 ms 3828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 612 KB Output is correct
2 Correct 433 ms 2368 KB Output is correct
3 Correct 1438 ms 16568 KB Output is correct
4 Correct 371 ms 4480 KB Output is correct
5 Correct 588 ms 9656 KB Output is correct
6 Execution timed out 2071 ms 213316 KB Time limit exceeded
7 Correct 7 ms 512 KB Output is correct
8 Correct 7 ms 580 KB Output is correct
9 Correct 18 ms 832 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Correct 5 ms 640 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 439 ms 2176 KB Output is correct
14 Correct 251 ms 1536 KB Output is correct
15 Correct 56 ms 1408 KB Output is correct
16 Correct 272 ms 1280 KB Output is correct
17 Correct 1224 ms 4792 KB Output is correct
18 Correct 247 ms 4472 KB Output is correct
19 Correct 377 ms 4288 KB Output is correct
20 Correct 382 ms 3840 KB Output is correct
21 Correct 895 ms 9720 KB Output is correct
22 Correct 545 ms 9468 KB Output is correct
23 Execution timed out 2056 ms 8436 KB Time limit exceeded
24 Correct 553 ms 9528 KB Output is correct
25 Correct 914 ms 16312 KB Output is correct
26 Execution timed out 2063 ms 209632 KB Time limit exceeded
27 Execution timed out 2064 ms 213220 KB Time limit exceeded
28 Execution timed out 2063 ms 213204 KB Time limit exceeded
29 Execution timed out 2064 ms 213284 KB Time limit exceeded
30 Execution timed out 2043 ms 212948 KB Time limit exceeded
31 Execution timed out 2063 ms 16612 KB Time limit exceeded
32 Execution timed out 2063 ms 213268 KB Time limit exceeded