Submission #101645

# Submission time Handle Problem Language Result Execution time Memory
101645 2019-03-19T06:39:05 Z SomeoneUnknown Tracks in the Snow (BOI13_tracks) C++14
52.9167 / 100
2000 ms 227176 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)/2+2];
    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)/2+2; 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 1280 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 11 ms 2176 KB Output is correct
5 Correct 4 ms 640 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 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 4 ms 640 KB Output is correct
11 Correct 5 ms 896 KB Output is correct
12 Correct 8 ms 768 KB Output is correct
13 Correct 4 ms 640 KB Output is correct
14 Correct 4 ms 640 KB Output is correct
15 Correct 15 ms 1024 KB Output is correct
16 Correct 17 ms 1280 KB Output is correct
17 Correct 10 ms 1024 KB Output is correct
18 Correct 13 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 3328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Correct 55 ms 3192 KB Output is correct
3 Runtime error 90 ms 37368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Correct 65 ms 5880 KB Output is correct
5 Runtime error 56 ms 22340 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Execution timed out 2057 ms 155256 KB Time limit exceeded
7 Runtime error 6 ms 3456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 6 ms 3328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Correct 5 ms 1920 KB Output is correct
10 Runtime error 6 ms 3328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 6 ms 3328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Correct 45 ms 3320 KB Output is correct
14 Correct 26 ms 2176 KB Output is correct
15 Runtime error 10 ms 3812 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Correct 25 ms 1912 KB Output is correct
17 Runtime error 150 ms 14076 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 32 ms 11128 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Correct 55 ms 5752 KB Output is correct
20 Runtime error 22 ms 9856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 46 ms 22904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 51 ms 22392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 313 ms 24696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 54 ms 22520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 87 ms 37496 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Correct 1278 ms 215684 KB Output is correct
27 Correct 1805 ms 199228 KB Output is correct
28 Execution timed out 2041 ms 154984 KB Time limit exceeded
29 Execution timed out 2067 ms 139544 KB Time limit exceeded
30 Correct 1689 ms 191168 KB Output is correct
31 Correct 1004 ms 19832 KB Output is correct
32 Correct 1359 ms 227176 KB Output is correct