Submission #518764

# Submission time Handle Problem Language Result Execution time Memory
518764 2022-01-24T14:48:29 Z neonaht Tracks in the Snow (BOI13_tracks) C++14
100 / 100
1495 ms 46796 KB
#include <bits/stdc++.h>
using namespace std;
const int SZ=4004;
char an[SZ][SZ],usx[]={'R','F'};
int dx[]={-1,0,1,0},dy[]={0,1,0,-1},chx;

struct A {
    int x,y,t;
};

int main() {
    int w,h,res(0);
    cin >> h >> w;
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) cin >> an[i][j];
    }
    queue <A> hx[2];
    hx[chx].push({0,0,(an[0][0]=='R' ? 0:1)});
    an[0][0]='*';
    while(!hx[chx].empty()) {
        while(!hx[chx].empty()) {
            auto o=hx[chx].front();
            hx[chx].pop();

            for(int i=0;i<4;i++) {
                int xx=o.x+dx[i],yy=o.y+dy[i];
                if(xx<0 || yy<0 || xx>h-1 || yy>w-1 || an[xx][yy]=='*') continue;
                if(an[xx][yy]==usx[o.t]) hx[chx].push({xx,yy,o.t}),an[xx][yy]='*';
                else if(an[xx][yy]==usx[1-o.t]) hx[1-chx].push({xx,yy,1-o.t}),an[xx][yy]='*';
            }
        }
        ++res;
        chx=1-chx;
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2508 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Correct 14 ms 2456 KB Output is correct
5 Correct 6 ms 1484 KB Output is correct
6 Correct 0 ms 300 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 680 KB Output is correct
10 Correct 6 ms 1328 KB Output is correct
11 Correct 4 ms 1100 KB Output is correct
12 Correct 9 ms 1476 KB Output is correct
13 Correct 6 ms 1484 KB Output is correct
14 Correct 6 ms 1452 KB Output is correct
15 Correct 22 ms 2396 KB Output is correct
16 Correct 23 ms 2504 KB Output is correct
17 Correct 20 ms 2500 KB Output is correct
18 Correct 15 ms 2508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 15276 KB Output is correct
2 Correct 116 ms 6652 KB Output is correct
3 Correct 983 ms 31756 KB Output is correct
4 Correct 230 ms 11308 KB Output is correct
5 Correct 585 ms 20804 KB Output is correct
6 Correct 1411 ms 46796 KB Output is correct
7 Correct 9 ms 15948 KB Output is correct
8 Correct 9 ms 15284 KB Output is correct
9 Correct 5 ms 456 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 9 ms 15680 KB Output is correct
12 Correct 2 ms 824 KB Output is correct
13 Correct 115 ms 6656 KB Output is correct
14 Correct 66 ms 4680 KB Output is correct
15 Correct 64 ms 5088 KB Output is correct
16 Correct 51 ms 2408 KB Output is correct
17 Correct 307 ms 12124 KB Output is correct
18 Correct 259 ms 12024 KB Output is correct
19 Correct 241 ms 11300 KB Output is correct
20 Correct 224 ms 10516 KB Output is correct
21 Correct 616 ms 21416 KB Output is correct
22 Correct 596 ms 20832 KB Output is correct
23 Correct 613 ms 17592 KB Output is correct
24 Correct 600 ms 21352 KB Output is correct
25 Correct 1080 ms 31584 KB Output is correct
26 Correct 952 ms 25964 KB Output is correct
27 Correct 1308 ms 34000 KB Output is correct
28 Correct 1495 ms 46664 KB Output is correct
29 Correct 1476 ms 44128 KB Output is correct
30 Correct 1375 ms 42316 KB Output is correct
31 Correct 1033 ms 23540 KB Output is correct
32 Correct 1329 ms 32864 KB Output is correct