Submission #534378

# Submission time Handle Problem Language Result Execution time Memory
534378 2022-03-08T06:15:33 Z aadit_ambadkar Tracks in the Snow (BOI13_tracks) C++11
0 / 100
2000 ms 78804 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 1 ms 460 KB Output isn't correct
3 Incorrect 1 ms 716 KB Output isn't correct
4 Incorrect 17 ms 4812 KB Output isn't correct
5 Incorrect 2 ms 2892 KB Output isn't correct
6 Incorrect 1 ms 496 KB Output isn't correct
7 Incorrect 1 ms 720 KB Output isn't correct
8 Incorrect 2 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 6 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 4 ms 5068 KB Output isn't correct
17 Incorrect 3 ms 4940 KB Output isn't correct
18 Incorrect 28 ms 4852 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 30796 KB Output isn't correct
2 Incorrect 13 ms 16316 KB Output isn't correct
3 Incorrect 71 ms 78652 KB Output isn't correct
4 Incorrect 24 ms 29880 KB Output isn't correct
5 Incorrect 51 ms 59056 KB Output isn't correct
6 Execution timed out 2068 ms 78780 KB Time limit exceeded
7 Incorrect 13 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 68 ms 57912 KB Execution killed with signal 11
12 Incorrect 1 ms 1484 KB Output isn't correct
13 Incorrect 12 ms 16332 KB Output isn't correct
14 Incorrect 7 ms 11084 KB Output isn't correct
15 Incorrect 10 ms 12172 KB Output isn't correct
16 Incorrect 5 ms 5964 KB Output isn't correct
17 Incorrect 22 ms 32132 KB Output isn't correct
18 Incorrect 23 ms 31812 KB Output isn't correct
19 Incorrect 23 ms 29900 KB Output isn't correct
20 Incorrect 26 ms 27712 KB Output isn't correct
21 Incorrect 48 ms 61084 KB Output isn't correct
22 Incorrect 44 ms 59004 KB Output isn't correct
23 Incorrect 55 ms 49348 KB Output isn't correct
24 Incorrect 48 ms 60612 KB Output isn't correct
25 Incorrect 70 ms 78608 KB Output isn't correct
26 Execution timed out 2088 ms 68952 KB Time limit exceeded
27 Execution timed out 2088 ms 78760 KB Time limit exceeded
28 Execution timed out 2090 ms 78788 KB Time limit exceeded
29 Execution timed out 2085 ms 78704 KB Time limit exceeded
30 Execution timed out 2080 ms 77128 KB Time limit exceeded
31 Incorrect 52 ms 63044 KB Output isn't correct
32 Incorrect 312 ms 78804 KB Output isn't correct