Submission #534377

# Submission time Handle Problem Language Result Execution time Memory
534377 2022-03-08T06:15:20 Z aadit_ambadkar Tracks in the Snow (BOI13_tracks) C++17
0 / 100
2000 ms 79644 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;
    F0R(i, n) {
        string s;
        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 < 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 (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 (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}});
        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}});
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5068 KB Output isn't correct
2 Incorrect 0 ms 460 KB Output isn't correct
3 Incorrect 1 ms 716 KB Output isn't correct
4 Incorrect 16 ms 4856 KB Output isn't correct
5 Incorrect 3 ms 2892 KB Output isn't correct
6 Incorrect 0 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 3 ms 4976 KB Output isn't correct
18 Incorrect 17 ms 4852 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 69 ms 61412 KB Execution killed with signal 11
2 Incorrect 11 ms 16332 KB Output isn't correct
3 Incorrect 71 ms 78716 KB Output isn't correct
4 Incorrect 22 ms 29984 KB Output isn't correct
5 Incorrect 48 ms 59088 KB Output isn't correct
6 Execution timed out 2087 ms 78792 KB Time limit exceeded
7 Runtime error 59 ms 49408 KB Execution killed with signal 11
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 Incorrect 14 ms 31684 KB Output isn't correct
12 Incorrect 1 ms 1484 KB Output isn't correct
13 Incorrect 11 ms 16348 KB Output isn't correct
14 Incorrect 7 ms 11036 KB Output isn't correct
15 Incorrect 8 ms 12108 KB Output isn't correct
16 Incorrect 4 ms 5964 KB Output isn't correct
17 Incorrect 23 ms 32068 KB Output isn't correct
18 Incorrect 22 ms 31820 KB Output isn't correct
19 Incorrect 22 ms 30004 KB Output isn't correct
20 Incorrect 19 ms 27728 KB Output isn't correct
21 Incorrect 45 ms 61032 KB Output isn't correct
22 Incorrect 45 ms 59000 KB Output isn't correct
23 Incorrect 42 ms 49300 KB Output isn't correct
24 Incorrect 47 ms 60596 KB Output isn't correct
25 Incorrect 70 ms 78648 KB Output isn't correct
26 Execution timed out 2082 ms 68964 KB Time limit exceeded
27 Execution timed out 2085 ms 78788 KB Time limit exceeded
28 Execution timed out 2093 ms 78764 KB Time limit exceeded
29 Execution timed out 2069 ms 79644 KB Time limit exceeded
30 Execution timed out 2057 ms 77968 KB Time limit exceeded
31 Incorrect 53 ms 63116 KB Output isn't correct
32 Incorrect 321 ms 79480 KB Output isn't correct