Submission #101642

# Submission time Handle Problem Language Result Execution time Memory
101642 2019-03-19T06:37:16 Z SomeoneUnknown Tracks in the Snow (BOI13_tracks) C++14
63.8542 / 100
2000 ms 229860 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;
    }
    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].front();
        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 17 ms 1536 KB Output is correct
2 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Correct 2 ms 384 KB Output is correct
4 Correct 13 ms 2432 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 5 ms 768 KB Output is correct
11 Correct 5 ms 1024 KB Output is correct
12 Correct 9 ms 1024 KB Output is correct
13 Correct 4 ms 896 KB Output is correct
14 Correct 4 ms 896 KB Output is correct
15 Correct 18 ms 1508 KB Output is correct
16 Correct 17 ms 1664 KB Output is correct
17 Correct 9 ms 1280 KB Output is correct
18 Correct 12 ms 2432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 5888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Correct 51 ms 4156 KB Output is correct
3 Runtime error 106 ms 42928 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Correct 79 ms 7160 KB Output is correct
5 Runtime error 56 ms 26368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Correct 1978 ms 158048 KB Output is correct
7 Runtime error 10 ms 6144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 10 ms 5888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Correct 7 ms 3200 KB Output is correct
10 Correct 6 ms 3072 KB Output is correct
11 Correct 9 ms 3072 KB Output is correct
12 Runtime error 3 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Correct 52 ms 4088 KB Output is correct
14 Correct 28 ms 2808 KB Output is correct
15 Runtime error 10 ms 5248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Correct 23 ms 2560 KB Output is correct
17 Correct 127 ms 8500 KB Output is correct
18 Runtime error 29 ms 13688 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Correct 75 ms 7160 KB Output is correct
20 Runtime error 26 ms 12408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 64 ms 27256 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 61 ms 26360 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Correct 245 ms 14320 KB Output is correct
24 Runtime error 70 ms 26592 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 121 ms 42856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Correct 1268 ms 217912 KB Output is correct
27 Correct 1661 ms 202052 KB Output is correct
28 Execution timed out 2064 ms 158064 KB Time limit exceeded
29 Execution timed out 2037 ms 142088 KB Time limit exceeded
30 Correct 1834 ms 193648 KB Output is correct
31 Correct 1064 ms 21944 KB Output is correct
32 Correct 1381 ms 229860 KB Output is correct