답안 #534364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
534364 2022-03-08T06:04:58 Z aadit_ambadkar Tracks in the Snow (BOI13_tracks) C++17
0 / 100
2000 ms 78840 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 (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 (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 < 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;
}
# 결과 실행 시간 메모리 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 20 ms 4808 KB Output isn't correct
5 Incorrect 2 ms 2892 KB Output isn't correct
6 Incorrect 1 ms 344 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 2552 KB Output isn't correct
11 Incorrect 10 ms 2072 KB Output isn't correct
12 Incorrect 2 ms 2892 KB Output isn't correct
13 Incorrect 3 ms 2892 KB Output isn't correct
14 Incorrect 2 ms 2892 KB Output isn't correct
15 Incorrect 4 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 22 ms 4812 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 30856 KB Output isn't correct
2 Incorrect 11 ms 16332 KB Output isn't correct
3 Incorrect 71 ms 78676 KB Output isn't correct
4 Incorrect 24 ms 29880 KB Output isn't correct
5 Incorrect 43 ms 59016 KB Output isn't correct
6 Execution timed out 2073 ms 78768 KB Time limit exceeded
7 Incorrect 14 ms 32204 KB Output isn't correct
8 Incorrect 15 ms 30808 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 31604 KB Output isn't correct
12 Incorrect 1 ms 1484 KB Output isn't correct
13 Incorrect 14 ms 16232 KB Output isn't correct
14 Incorrect 7 ms 10988 KB Output isn't correct
15 Incorrect 10 ms 12064 KB Output isn't correct
16 Incorrect 5 ms 5964 KB Output isn't correct
17 Incorrect 21 ms 32144 KB Output isn't correct
18 Incorrect 24 ms 31812 KB Output isn't correct
19 Incorrect 22 ms 29932 KB Output isn't correct
20 Incorrect 23 ms 27604 KB Output isn't correct
21 Incorrect 48 ms 61028 KB Output isn't correct
22 Incorrect 54 ms 59076 KB Output isn't correct
23 Incorrect 40 ms 49348 KB Output isn't correct
24 Incorrect 51 ms 60484 KB Output isn't correct
25 Incorrect 72 ms 78672 KB Output isn't correct
26 Execution timed out 2078 ms 68884 KB Time limit exceeded
27 Execution timed out 2077 ms 78660 KB Time limit exceeded
28 Execution timed out 2072 ms 78664 KB Time limit exceeded
29 Execution timed out 2082 ms 78840 KB Time limit exceeded
30 Execution timed out 2081 ms 77104 KB Time limit exceeded
31 Incorrect 49 ms 63044 KB Output isn't correct
32 Incorrect 322 ms 78772 KB Output isn't correct