답안 #895553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895553 2023-12-30T08:56:18 Z 123456321 Tracks in the Snow (BOI13_tracks) C++17
2.1875 / 100
261 ms 93448 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1000000007;
int n,m;
#define pb push_back
#define mp make_pair
vector<vector<pair<int,int>>> adj;


void solve()
{
    cin >> n >>m ;
    vector<string> snow(n);
    for(int i = 0;i<n;i++)cin >> snow[i];
    deque<pair<int,int>> q;
    vector<vector<int>> dist(n,vector<int>(m,0));    
    vector<vector<int>> dir = {{1,0},{-1,0},{0,1},{0,-1}};
    q.push_back({0,0});
    dist[0][0] = 1;
    int ans = 1;
    while(!q.empty())
    {
        auto curr = q.front();
        q.pop_front();
        int x = curr.first;
        int y = curr.second;
        ans = max(ans,dist[x][y]);
        for(auto d : dir)
        {
            int nx = x + d[0];
            int ny = y + d[1];
            if(nx < 0 || nx >= n || ny < 0 || ny >= m||snow[nx][ny]=='.')continue;
            if(snow[nx][ny] == snow[x][y])
            {
                if(dist[nx][ny] > dist[x][y])
                {
                    dist[nx][ny] = dist[x][y];
                    q.push_front({nx,ny});
                }
            }
            else
            {
                if(dist[nx][ny] > dist[x][y] + 1)
                {
                    dist[nx][ny] = dist[x][y] + 1;
                    q.push_back({nx,ny});
                }
            }
        }
    }
    cout << ans << "\n";
    return;
}
int main()
{
    int tests = 1;
    //cin >> tests;
    int i = 1;
    while (i <= tests)
    {
        //cout << "Case #"<< i<< ": ";
        solve();
        if(i!=tests)cout << "\n";
        i++;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1880 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 3 ms 1116 KB Output isn't correct
5 Incorrect 2 ms 860 KB Output isn't correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 1 ms 604 KB Output isn't correct
11 Incorrect 1 ms 604 KB Output isn't correct
12 Incorrect 2 ms 860 KB Output isn't correct
13 Incorrect 2 ms 860 KB Output isn't correct
14 Incorrect 2 ms 860 KB Output isn't correct
15 Incorrect 4 ms 1884 KB Output isn't correct
16 Incorrect 4 ms 1884 KB Output isn't correct
17 Incorrect 4 ms 1628 KB Output isn't correct
18 Incorrect 3 ms 1116 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 856 KB Output isn't correct
2 Incorrect 23 ms 8796 KB Output isn't correct
3 Incorrect 242 ms 93396 KB Output isn't correct
4 Incorrect 56 ms 22100 KB Output isn't correct
5 Incorrect 141 ms 47004 KB Output isn't correct
6 Incorrect 232 ms 93448 KB Output isn't correct
7 Incorrect 2 ms 856 KB Output isn't correct
8 Incorrect 2 ms 860 KB Output isn't correct
9 Incorrect 1 ms 604 KB Output isn't correct
10 Incorrect 1 ms 604 KB Output isn't correct
11 Incorrect 1 ms 860 KB Output isn't correct
12 Incorrect 1 ms 348 KB Output isn't correct
13 Incorrect 24 ms 8816 KB Output isn't correct
14 Incorrect 14 ms 5656 KB Output isn't correct
15 Incorrect 15 ms 6068 KB Output isn't correct
16 Incorrect 9 ms 3676 KB Output isn't correct
17 Incorrect 59 ms 23892 KB Output isn't correct
18 Incorrect 60 ms 23636 KB Output isn't correct
19 Incorrect 60 ms 22300 KB Output isn't correct
20 Incorrect 50 ms 20492 KB Output isn't correct
21 Incorrect 134 ms 48804 KB Output isn't correct
22 Incorrect 133 ms 46928 KB Output isn't correct
23 Incorrect 114 ms 40132 KB Output isn't correct
24 Incorrect 134 ms 48112 KB Output isn't correct
25 Incorrect 235 ms 93348 KB Output isn't correct
26 Correct 179 ms 61636 KB Output is correct
27 Incorrect 243 ms 93256 KB Output isn't correct
28 Incorrect 238 ms 93268 KB Output isn't correct
29 Incorrect 233 ms 93264 KB Output isn't correct
30 Incorrect 238 ms 91516 KB Output isn't correct
31 Incorrect 147 ms 52816 KB Output isn't correct
32 Incorrect 261 ms 93268 KB Output isn't correct