답안 #920090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
920090 2024-02-02T03:50:11 Z thienbao1602 Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
691 ms 34412 KB
#include    <bits/stdc++.h>
#define SKY
#define ll long long
#define ld long double
#define MASK(x) (1LL << x)
#define sz(x) (int)x.size()
#define ii pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define set0(d) memset(d, 0, sizeof(d))
using namespace std;

const int LOG = 20;
const int base = 311;
const ll inf = 1e18;
const int block = 400;
const ll MOD = 1e9 + 7;
const int mxN = 1e6 + 66;
const int mxN2D = 4e3 + 55;
const int x[] = {0, 1, 0, -1};
const int y[] = {1, 0, -1, 0};

int H, W;
char grid[mxN2D][mxN2D];

bool safe(int x, int y)
{
    return (x >= 0 && x < H && y >= 0 && y < W);
}

void solve()
{
    cin >> H >> W;
    for (int r=0; r<H; r++)
    {
        for(int c=0; c<W; c++)
        {
            cin >> grid[r][c];
        }
    }

    char crossed_animal = grid[H - 1][W - 1];
    vector<vector<bool>> vis(H, vector<bool>(W, false));
    vis[H - 1][W - 1] = true;
    queue<ii> pq;
    pq.push(mp(H - 1, W - 1));

    bool other_animal = false;
    while(!pq.empty())
    {
        ii cell = pq.front();
        int u = cell.fi;
        int v = cell.se;

        for (int i=0; i<4; i++)
        {
            int ux = u + x[i];
            int vx = v + y[i];

            if (safe(ux, vx) && grid[ux][vx] != '.' && !vis[ux][vx])
            {
                if (crossed_animal != grid[ux][vx])
                {
                    other_animal = true;
                }
                pq.push(mp(ux, vx));
                vis[ux][vx] = true;
            }
        }
        pq.pop();
    }
    cout << 1 + other_animal;
}

int main()
{
    ios_base::sync_with_stdio(false);
    #ifdef SKY
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    #endif //SKY
    solve();
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 2908 KB Output isn't correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Incorrect 1 ms 2652 KB Output isn't correct
4 Incorrect 6 ms 2648 KB Output isn't correct
5 Incorrect 2 ms 2652 KB Output isn't correct
6 Incorrect 1 ms 344 KB Output isn't correct
7 Incorrect 1 ms 2516 KB Output isn't correct
8 Incorrect 1 ms 2648 KB Output isn't correct
9 Incorrect 1 ms 2652 KB Output isn't correct
10 Incorrect 2 ms 2652 KB Output isn't correct
11 Incorrect 2 ms 2652 KB Output isn't correct
12 Incorrect 3 ms 2784 KB Output isn't correct
13 Incorrect 3 ms 2648 KB Output isn't correct
14 Incorrect 3 ms 2648 KB Output isn't correct
15 Incorrect 8 ms 2760 KB Output isn't correct
16 Incorrect 10 ms 2780 KB Output isn't correct
17 Incorrect 7 ms 2904 KB Output isn't correct
18 Incorrect 7 ms 3164 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 15960 KB Output isn't correct
2 Incorrect 34 ms 8536 KB Output isn't correct
3 Incorrect 268 ms 34012 KB Output isn't correct
4 Incorrect 67 ms 12880 KB Output isn't correct
5 Incorrect 193 ms 22752 KB Output isn't correct
6 Incorrect 686 ms 34032 KB Output isn't correct
7 Incorrect 4 ms 16476 KB Output isn't correct
8 Incorrect 4 ms 15704 KB Output isn't correct
9 Incorrect 2 ms 600 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Incorrect 5 ms 16220 KB Output isn't correct
12 Incorrect 1 ms 2652 KB Output isn't correct
13 Incorrect 37 ms 8536 KB Output isn't correct
14 Incorrect 20 ms 5756 KB Output isn't correct
15 Incorrect 19 ms 5724 KB Output isn't correct
16 Incorrect 22 ms 3420 KB Output isn't correct
17 Incorrect 90 ms 13300 KB Output isn't correct
18 Incorrect 77 ms 13280 KB Output isn't correct
19 Incorrect 68 ms 12912 KB Output isn't correct
20 Incorrect 62 ms 12696 KB Output isn't correct
21 Incorrect 161 ms 23324 KB Output isn't correct
22 Incorrect 194 ms 22884 KB Output isn't correct
23 Incorrect 181 ms 19536 KB Output isn't correct
24 Incorrect 175 ms 22864 KB Output isn't correct
25 Incorrect 381 ms 33924 KB Output isn't correct
26 Correct 506 ms 28916 KB Output is correct
27 Incorrect 675 ms 34412 KB Output isn't correct
28 Incorrect 691 ms 34156 KB Output isn't correct
29 Incorrect 671 ms 34284 KB Output isn't correct
30 Incorrect 673 ms 33948 KB Output isn't correct
31 Incorrect 409 ms 26608 KB Output isn't correct
32 Incorrect 607 ms 34132 KB Output isn't correct