Submission #101640

# Submission time Handle Problem Language Result Execution time Memory
101640 2019-03-19T06:36:21 Z SomeoneUnknown Tracks in the Snow (BOI13_tracks) C++14
50.7292 / 100
2000 ms 276340 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];
    bool written[r][c+2];
    for(int i = 0; i < r; i++){
        //cin >> m[i];
        //cout << "read";
        scanf("%s", &m[i]);
        //for(int j = 0; j < c; j++) written[i][j] = false;
    }
    priority_queue<ii> vable[r+c];
    vable[0].push(mii(0, 0));
    vable[0].push(mii(r-1, c-1));
    //written[0][0] = written[r-1][c-1] = true;
    int most = 0;
    for(int que = 0; que < r+c; que++){
    while(!vable[que].empty()){
        ii ving = vable[que].top();
        vable[que].pop();
        int y = ving.first;
        int x = ving.second;
        if(m[y][x] == '.') continue;
        most = max(most, que);
        if(y != r-1){
            vable[que+(m[y][x]!=m[y+1][x])].push(mii(y+1, x));
        }
        if(x != c-1){
            vable[que+(m[y][x]!=m[y][x+1])].push(mii(y, x+1));
        }
        if(y != 0){
            vable[que+(m[y][x]!=m[y-1][x])].push(mii(y-1, x));
        }
        if(x != 0){
            vable[que+(m[y][x]!=m[y][x-1])].push(mii(y, x-1));
        }
        m[y][x] = '.';
    }
    }
    printf("%d", most+1);//*/
}
/*
5 8
FFRF....
.FRRR...
.FFFFF..
..RRRFFR
.....FFF
*/

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:26:26: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[(c + 2)]' [-Wformat=]
         scanf("%s", &m[i]);
                     ~~~~~^
tracks.cpp:22:10: warning: unused variable 'written' [-Wunused-variable]
     bool written[r][c+2];
          ^~~~~~~
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:26: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 145 ms 6512 KB Output is correct
2 Runtime error 2 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Correct 3 ms 388 KB Output is correct
4 Correct 103 ms 3812 KB Output is correct
5 Correct 14 ms 1152 KB Output is correct
6 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Correct 2 ms 384 KB Output is correct
8 Correct 6 ms 512 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 16 ms 1280 KB Output is correct
11 Correct 23 ms 1528 KB Output is correct
12 Correct 48 ms 2548 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 14 ms 1152 KB Output is correct
15 Correct 110 ms 5556 KB Output is correct
16 Correct 143 ms 6364 KB Output is correct
17 Correct 66 ms 3832 KB Output is correct
18 Correct 100 ms 3872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Correct 377 ms 20392 KB Output is correct
3 Runtime error 124 ms 37128 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Correct 315 ms 22216 KB Output is correct
5 Runtime error 54 ms 20472 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Execution timed out 2065 ms 133332 KB Time limit exceeded
7 Runtime error 9 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 7 ms 1664 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Correct 16 ms 1404 KB Output is correct
10 Correct 6 ms 768 KB Output is correct
11 Correct 7 ms 768 KB Output is correct
12 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Correct 369 ms 20436 KB Output is correct
14 Correct 204 ms 12536 KB Output is correct
15 Runtime error 11 ms 3328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Correct 221 ms 11456 KB Output is correct
17 Correct 1016 ms 50164 KB Output is correct
18 Runtime error 34 ms 9848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Correct 373 ms 22392 KB Output is correct
20 Runtime error 34 ms 10360 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 68 ms 23288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 52 ms 19936 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Correct 1767 ms 97156 KB Output is correct
24 Runtime error 54 ms 20728 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 95 ms 34552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Execution timed out 2065 ms 276340 KB Time limit exceeded
27 Execution timed out 2092 ms 148616 KB Time limit exceeded
28 Execution timed out 2058 ms 133040 KB Time limit exceeded
29 Execution timed out 2045 ms 124028 KB Time limit exceeded
30 Execution timed out 2058 ms 148408 KB Time limit exceeded
31 Execution timed out 2037 ms 70080 KB Time limit exceeded
32 Execution timed out 2071 ms 148936 KB Time limit exceeded