Submission #31345

# Submission time Handle Problem Language Result Execution time Memory
31345 2017-08-19T02:22:31 Z imaxblue Tracks in the Snow (BOI13_tracks) C++14
0 / 100
259 ms 33348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)

int n, m, X, Y, ans, t;
char g[4005][4005];
bool u[4005][4005];
queue<pii> q[2];
void bfs(){
    q[0].push(mp(1, 1));
    for (ans=0; !q[t].empty(); ans++){
        //cout << "*";
        while(!q[t].empty()){
            X=q[t].front().x; Y=q[t].front().y; q[t].pop();
            if (u[X][Y]) continue;
            u[X][Y]=1;
            if (!(X+1>n || g[X+1][Y]=='.' || u[X+1][Y]))
            q[g[X+1][Y]!=g[X][Y]].push(mp(X+1, Y));
            if (!(X-1<1 || g[X-1][Y]=='.' || u[X-1][Y]))
            q[g[X-1][Y]!=g[X][Y]].push(mp(X-1, Y));
            if (!(Y+1>m || g[X][Y+1]=='.' || u[X][Y+1]))
            q[g[X][Y+1]!=g[X][Y]].push(mp(X, Y+1));
            if (!(Y-1<1 || g[X][Y-1]=='.' || u[X][Y-1]))
            q[g[X][Y-1]!=g[X][Y]].push(mp(X, Y-1));
        }
        t=!t;
    }
}
int main(){
    scanf("%i%i", &n, &m);
    fox1(l, n){
        fox1(l2, m){
            scanf(" %s", g[l]);
        }
    }
    bfs();
    cout << ans << endl;
    return 0;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:51:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i", &n, &m);
                          ^
tracks.cpp:54:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf(" %s", g[l]);
                               ^
# Verdict Execution time Memory Grader output
1 Incorrect 163 ms 33348 KB Output isn't correct
2 Incorrect 0 ms 33348 KB Output isn't correct
3 Incorrect 6 ms 33348 KB Output isn't correct
4 Runtime error 86 ms 33348 KB Execution timed out (wall clock limit exceeded)
5 Incorrect 69 ms 33348 KB Output isn't correct
6 Incorrect 0 ms 33348 KB Output isn't correct
7 Incorrect 3 ms 33348 KB Output isn't correct
8 Incorrect 0 ms 33348 KB Output isn't correct
9 Incorrect 16 ms 33348 KB Output isn't correct
10 Incorrect 63 ms 33348 KB Output isn't correct
11 Incorrect 16 ms 33348 KB Output isn't correct
12 Incorrect 79 ms 33348 KB Output isn't correct
13 Incorrect 66 ms 33348 KB Output isn't correct
14 Incorrect 56 ms 33348 KB Output isn't correct
15 Runtime error 23 ms 33348 KB Execution timed out (wall clock limit exceeded)
16 Runtime error 133 ms 33348 KB Execution timed out (wall clock limit exceeded)
17 Runtime error 76 ms 33348 KB Execution timed out (wall clock limit exceeded)
18 Runtime error 66 ms 33348 KB Execution timed out (wall clock limit exceeded)
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 33348 KB Output isn't correct
2 Runtime error 73 ms 33348 KB Execution timed out (wall clock limit exceeded)
3 Runtime error 189 ms 33348 KB Execution timed out (wall clock limit exceeded)
4 Runtime error 149 ms 33348 KB Execution timed out (wall clock limit exceeded)
5 Runtime error 129 ms 33348 KB Execution timed out (wall clock limit exceeded)
6 Runtime error 96 ms 33348 KB Execution timed out (wall clock limit exceeded)
7 Incorrect 29 ms 33348 KB Output isn't correct
8 Incorrect 26 ms 33348 KB Output isn't correct
9 Incorrect 53 ms 33348 KB Output isn't correct
10 Incorrect 29 ms 33348 KB Output isn't correct
11 Incorrect 26 ms 33348 KB Output isn't correct
12 Incorrect 16 ms 33348 KB Output isn't correct
13 Runtime error 139 ms 33348 KB Execution timed out (wall clock limit exceeded)
14 Runtime error 126 ms 33348 KB Execution timed out (wall clock limit exceeded)
15 Runtime error 196 ms 33348 KB Execution timed out (wall clock limit exceeded)
16 Runtime error 206 ms 33348 KB Execution timed out (wall clock limit exceeded)
17 Runtime error 129 ms 33348 KB Execution timed out (wall clock limit exceeded)
18 Runtime error 69 ms 33348 KB Execution timed out (wall clock limit exceeded)
19 Runtime error 133 ms 33348 KB Execution timed out (wall clock limit exceeded)
20 Runtime error 83 ms 33348 KB Execution timed out (wall clock limit exceeded)
21 Runtime error 109 ms 33348 KB Execution timed out (wall clock limit exceeded)
22 Runtime error 113 ms 33348 KB Execution timed out (wall clock limit exceeded)
23 Runtime error 156 ms 33348 KB Execution timed out (wall clock limit exceeded)
24 Runtime error 139 ms 33348 KB Execution timed out (wall clock limit exceeded)
25 Runtime error 259 ms 33348 KB Execution timed out (wall clock limit exceeded)
26 Runtime error 139 ms 33348 KB Execution timed out (wall clock limit exceeded)
27 Runtime error 99 ms 33348 KB Execution timed out (wall clock limit exceeded)
28 Runtime error 233 ms 33348 KB Execution timed out (wall clock limit exceeded)
29 Runtime error 173 ms 33348 KB Execution timed out (wall clock limit exceeded)
30 Runtime error 149 ms 33348 KB Execution timed out (wall clock limit exceeded)
31 Runtime error 83 ms 33348 KB Execution timed out (wall clock limit exceeded)
32 Runtime error 199 ms 33348 KB Execution timed out (wall clock limit exceeded)