Submission #534370

# Submission time Handle Problem Language Result Execution time Memory
534370 2022-03-08T06:09:42 Z aadit_ambadkar Tracks in the Snow (BOI13_tracks) C++17
0 / 100
2000 ms 78992 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 < 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 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 1 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 1 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 4940 KB Output isn't correct
18 Incorrect 17 ms 4856 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 30832 KB Output isn't correct
2 Incorrect 11 ms 16332 KB Output isn't correct
3 Incorrect 76 ms 78616 KB Output isn't correct
4 Incorrect 26 ms 29916 KB Output isn't correct
5 Incorrect 44 ms 58976 KB Output isn't correct
6 Execution timed out 2085 ms 78824 KB Time limit exceeded
7 Runtime error 77 ms 63852 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 31588 KB Output isn't correct
12 Incorrect 1 ms 1484 KB Output isn't correct
13 Incorrect 13 ms 16460 KB Output isn't correct
14 Incorrect 9 ms 10984 KB Output isn't correct
15 Incorrect 7 ms 12108 KB Output isn't correct
16 Incorrect 6 ms 5912 KB Output isn't correct
17 Incorrect 23 ms 32076 KB Output isn't correct
18 Incorrect 23 ms 31836 KB Output isn't correct
19 Incorrect 23 ms 29940 KB Output isn't correct
20 Incorrect 20 ms 27632 KB Output isn't correct
21 Incorrect 47 ms 60996 KB Output isn't correct
22 Incorrect 55 ms 59020 KB Output isn't correct
23 Incorrect 42 ms 49276 KB Output isn't correct
24 Incorrect 45 ms 60580 KB Output isn't correct
25 Incorrect 67 ms 78788 KB Output isn't correct
26 Execution timed out 2086 ms 68848 KB Time limit exceeded
27 Execution timed out 2091 ms 78688 KB Time limit exceeded
28 Execution timed out 2104 ms 78660 KB Time limit exceeded
29 Execution timed out 2033 ms 78988 KB Time limit exceeded
30 Execution timed out 2032 ms 77404 KB Time limit exceeded
31 Incorrect 49 ms 63092 KB Output isn't correct
32 Incorrect 326 ms 78992 KB Output isn't correct