Submission #534369

# Submission time Handle Problem Language Result Execution time Memory
534369 2022-03-08T06:09:03 Z aadit_ambadkar Tracks in the Snow (BOI13_tracks) C++17
0 / 100
2000 ms 78848 KB
/*
    This code belongs to Aadit Ambadkar
    Date: 2022-03-07 21:34:47
    Problem: tis
*/
#include <bits/stdc++.h>
using namespace::std;

typedef long long ll;
#define F0R(i, n) for (int i = 0; i < n; i++)
#define R0F(i, n) for (int i = n-1; i >= 0; i--)
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define MOD 1000000007
#define FF first
#define SS second

int n, m;
int board[4005][4005];
bool vis[4005][4005];

int main() {
    fastio;
    cin >> n >> m;
    string s;
    F0R(i, n) {
        cin >> s;
        F0R(j, m) {
            if (s[i]=='F') board[i][j]=1;
            else if (s[i]=='R') board[i][j]=2;
            else board[i][j]=0;
            vis[i][j]=false;
        }
    }
    priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> pq;
    pq.push({1, {0, 0}});
    int ans = 0;
    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        int g = p.FF, u = p.SS.FF, v = p.SS.SS;
        if (vis[u][v]) continue;
        ans = max(ans, g);
        vis[u][v]=true;
        if (u > 0 && !vis[u-1][v] && board[u-1][v]!=0) pq.push({g+((board[u][v]==board[u-1][v]) ? 0 : 1), {u-1, v}});
        if (u < n-1 && !vis[u+1][v] && board[u+1][v]!=0) pq.push({g+((board[u][v]==board[u+1][v]) ? 0 : 1), {u+1, v}});
        if (v > 0 && !vis[u][v-1] && board[u][v-1]!=0) pq.push({g+((board[u][v]==board[u][v-1]) ? 0 : 1), {u, v-1}});
        if (v < m-1 && !vis[u][v+1] && board[u][v+1]!=0) pq.push({g+((board[u][v]==board[u][v+1]) ? 0 : 1), {u, v+1}});
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 5068 KB Output isn't correct
2 Incorrect 1 ms 460 KB Output isn't correct
3 Incorrect 1 ms 716 KB Output isn't correct
4 Incorrect 18 ms 4812 KB Output isn't correct
5 Incorrect 2 ms 2892 KB Output isn't correct
6 Incorrect 1 ms 460 KB Output isn't correct
7 Incorrect 1 ms 716 KB Output isn't correct
8 Incorrect 1 ms 716 KB Output isn't correct
9 Incorrect 1 ms 1100 KB Output isn't correct
10 Incorrect 2 ms 2508 KB Output isn't correct
11 Incorrect 7 ms 1996 KB Output isn't correct
12 Incorrect 2 ms 2892 KB Output isn't correct
13 Incorrect 2 ms 2892 KB Output isn't correct
14 Incorrect 2 ms 2892 KB Output isn't correct
15 Incorrect 3 ms 5196 KB Output isn't correct
16 Incorrect 3 ms 5068 KB Output isn't correct
17 Incorrect 4 ms 4940 KB Output isn't correct
18 Incorrect 18 ms 4852 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 30828 KB Output isn't correct
2 Incorrect 11 ms 16332 KB Output isn't correct
3 Incorrect 64 ms 78568 KB Output isn't correct
4 Incorrect 22 ms 29996 KB Output isn't correct
5 Incorrect 44 ms 59076 KB Output isn't correct
6 Execution timed out 2070 ms 78680 KB Time limit exceeded
7 Incorrect 18 ms 32204 KB Output isn't correct
8 Incorrect 13 ms 30796 KB Output isn't correct
9 Incorrect 1 ms 588 KB Output isn't correct
10 Incorrect 1 ms 460 KB Output isn't correct
11 Runtime error 22 ms 18252 KB Execution killed with signal 11
12 Incorrect 1 ms 1484 KB Output isn't correct
13 Incorrect 11 ms 16344 KB Output isn't correct
14 Incorrect 8 ms 11044 KB Output isn't correct
15 Incorrect 9 ms 12108 KB Output isn't correct
16 Incorrect 6 ms 5964 KB Output isn't correct
17 Incorrect 22 ms 32164 KB Output isn't correct
18 Incorrect 22 ms 31724 KB Output isn't correct
19 Incorrect 23 ms 29948 KB Output isn't correct
20 Incorrect 19 ms 27596 KB Output isn't correct
21 Incorrect 44 ms 60996 KB Output isn't correct
22 Incorrect 42 ms 59076 KB Output isn't correct
23 Incorrect 42 ms 49284 KB Output isn't correct
24 Incorrect 43 ms 60576 KB Output isn't correct
25 Incorrect 66 ms 78628 KB Output isn't correct
26 Execution timed out 2077 ms 68936 KB Time limit exceeded
27 Execution timed out 2082 ms 78672 KB Time limit exceeded
28 Execution timed out 2067 ms 78848 KB Time limit exceeded
29 Execution timed out 2092 ms 78660 KB Time limit exceeded
30 Execution timed out 2085 ms 77088 KB Time limit exceeded
31 Incorrect 46 ms 63104 KB Output isn't correct
32 Incorrect 332 ms 78772 KB Output isn't correct