Submission #875560

# Submission time Handle Problem Language Result Execution time Memory
875560 2023-11-20T03:56:11 Z 12345678 Tracks in the Snow (BOI13_tracks) C++17
0 / 100
2000 ms 826908 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[h][w];
    nq.push({1, 1});
    while (!nq.empty())
    {
        cnt++;
        q=nq;
        c=mp[nq.front().first][nq.front().second];
        while (!nq.empty()) nq.pop();
        while (!q.empty())
        {
            auto [x, y]=q.front();
            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;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2123 ms 765664 KB Time limit exceeded
2 Execution timed out 2115 ms 796104 KB Time limit exceeded
3 Execution timed out 2051 ms 798120 KB Time limit exceeded
4 Execution timed out 2068 ms 803160 KB Time limit exceeded
5 Execution timed out 2061 ms 799392 KB Time limit exceeded
6 Execution timed out 2091 ms 811556 KB Time limit exceeded
7 Execution timed out 2050 ms 798016 KB Time limit exceeded
8 Execution timed out 2093 ms 812952 KB Time limit exceeded
9 Execution timed out 2136 ms 826908 KB Time limit exceeded
10 Execution timed out 2092 ms 811692 KB Time limit exceeded
11 Execution timed out 2095 ms 813032 KB Time limit exceeded
12 Execution timed out 2097 ms 813308 KB Time limit exceeded
13 Execution timed out 2092 ms 809772 KB Time limit exceeded
14 Execution timed out 2085 ms 808452 KB Time limit exceeded
15 Execution timed out 2087 ms 798732 KB Time limit exceeded
16 Execution timed out 2081 ms 807360 KB Time limit exceeded
17 Execution timed out 2096 ms 795504 KB Time limit exceeded
18 Execution timed out 2092 ms 813772 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2052 ms 627648 KB Time limit exceeded
2 Execution timed out 2059 ms 800916 KB Time limit exceeded
3 Execution timed out 2055 ms 759288 KB Time limit exceeded
4 Execution timed out 2102 ms 809120 KB Time limit exceeded
5 Execution timed out 2052 ms 766740 KB Time limit exceeded
6 Execution timed out 2073 ms 764652 KB Time limit exceeded
7 Execution timed out 2051 ms 506940 KB Time limit exceeded
8 Execution timed out 2076 ms 632372 KB Time limit exceeded
9 Execution timed out 2059 ms 713256 KB Time limit exceeded
10 Execution timed out 2069 ms 273000 KB Time limit exceeded
11 Execution timed out 2080 ms 575972 KB Time limit exceeded
12 Execution timed out 2102 ms 814728 KB Time limit exceeded
13 Execution timed out 2138 ms 823404 KB Time limit exceeded
14 Execution timed out 2075 ms 797460 KB Time limit exceeded
15 Execution timed out 2098 ms 811284 KB Time limit exceeded
16 Execution timed out 2113 ms 819688 KB Time limit exceeded
17 Execution timed out 2078 ms 793172 KB Time limit exceeded
18 Execution timed out 2058 ms 791972 KB Time limit exceeded
19 Execution timed out 2073 ms 792088 KB Time limit exceeded
20 Execution timed out 2053 ms 783588 KB Time limit exceeded
21 Execution timed out 2047 ms 750468 KB Time limit exceeded
22 Execution timed out 2054 ms 743852 KB Time limit exceeded
23 Execution timed out 2095 ms 770144 KB Time limit exceeded
24 Execution timed out 2081 ms 770248 KB Time limit exceeded
25 Execution timed out 2060 ms 760576 KB Time limit exceeded
26 Execution timed out 2132 ms 794584 KB Time limit exceeded
27 Execution timed out 2037 ms 752568 KB Time limit exceeded
28 Execution timed out 2120 ms 783668 KB Time limit exceeded
29 Execution timed out 2063 ms 766056 KB Time limit exceeded
30 Execution timed out 2068 ms 764412 KB Time limit exceeded
31 Execution timed out 2080 ms 773656 KB Time limit exceeded
32 Execution timed out 2124 ms 784820 KB Time limit exceeded