답안 #875562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875562 2023-11-20T04:00:53 Z 12345678 Tracks in the Snow (BOI13_tracks) C++17
31.25 / 100
2000 ms 1048576 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=4e3+5;
int h, w, cnt, dx[4]={1, 0, 0, -1}, dy[4]={0, 1, -1, 0};
char mp[nx][nx], c;
queue<pair<int, int>> q, nq;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>h>>w;
    for (int i=1; i<=h; i++) for (int j=1; j<=w; j++) cin>>mp[i][j];
    nq.push({1, 1});
    while (!nq.empty())
    {
        cnt++;
        c=mp[nq.front().first][nq.front().second];
        while (!nq.empty()) q.push(nq.front()), nq.pop();
        while (!q.empty())
        {
            auto [x, y]=q.front();
            //cout<<cnt<<' '<<x<<' '<<y<<' '<<c<<'\n';
            mp[x][y]='.';
            q.pop();
            for (int i=0; i<4; i++)
            {
                int nx=x+dx[i], ny=y+dy[i];
                if (nx<1||nx>h||ny<1||ny>w||mp[nx][ny]=='.') continue;
                if (mp[nx][ny]==c) q.push({nx, ny});
                else nq.push({nx, ny});
            }
        }
    }
    cout<<cnt;
}

/*
4 5
FFRFR
RFFRF
FRFFR
FFRFF
*/
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2094 ms 847248 KB Time limit exceeded
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 2102 ms 260268 KB Time limit exceeded
4 Execution timed out 2101 ms 879464 KB Time limit exceeded
5 Execution timed out 2075 ms 900424 KB Time limit exceeded
6 Correct 1 ms 344 KB Output is correct
7 Execution timed out 2063 ms 257720 KB Time limit exceeded
8 Execution timed out 2059 ms 934040 KB Time limit exceeded
9 Correct 37 ms 3076 KB Output is correct
10 Execution timed out 2106 ms 756716 KB Time limit exceeded
11 Execution timed out 2104 ms 807164 KB Time limit exceeded
12 Execution timed out 2116 ms 977120 KB Time limit exceeded
13 Execution timed out 2079 ms 887640 KB Time limit exceeded
14 Execution timed out 2064 ms 857936 KB Time limit exceeded
15 Execution timed out 2076 ms 927968 KB Time limit exceeded
16 Execution timed out 2071 ms 918056 KB Time limit exceeded
17 Execution timed out 2067 ms 813880 KB Time limit exceeded
18 Execution timed out 2083 ms 875048 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 15452 KB Output is correct
2 Execution timed out 2114 ms 724240 KB Time limit exceeded
3 Execution timed out 2058 ms 468220 KB Time limit exceeded
4 Execution timed out 2061 ms 272808 KB Time limit exceeded
5 Correct 162 ms 19792 KB Output is correct
6 Execution timed out 2081 ms 853056 KB Time limit exceeded
7 Correct 3 ms 15964 KB Output is correct
8 Correct 3 ms 15452 KB Output is correct
9 Execution timed out 2116 ms 606916 KB Time limit exceeded
10 Correct 1 ms 348 KB Output is correct
11 Correct 3 ms 15708 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Execution timed out 2116 ms 722124 KB Time limit exceeded
14 Execution timed out 2099 ms 907740 KB Time limit exceeded
15 Correct 16 ms 5720 KB Output is correct
16 Execution timed out 2109 ms 700396 KB Time limit exceeded
17 Execution timed out 2086 ms 453160 KB Time limit exceeded
18 Correct 64 ms 12116 KB Output is correct
19 Execution timed out 2054 ms 271688 KB Time limit exceeded
20 Execution timed out 2024 ms 220896 KB Time limit exceeded
21 Execution timed out 2061 ms 251164 KB Time limit exceeded
22 Correct 165 ms 19792 KB Output is correct
23 Execution timed out 2071 ms 298860 KB Time limit exceeded
24 Correct 144 ms 19720 KB Output is correct
25 Correct 265 ms 28412 KB Output is correct
26 Execution timed out 2136 ms 812148 KB Time limit exceeded
27 Execution timed out 2122 ms 791376 KB Time limit exceeded
28 Execution timed out 2057 ms 847100 KB Time limit exceeded
29 Execution timed out 2134 ms 839268 KB Time limit exceeded
30 Execution timed out 2065 ms 949752 KB Time limit exceeded
31 Execution timed out 2067 ms 901304 KB Time limit exceeded
32 Execution timed out 2122 ms 1048576 KB Time limit exceeded