답안 #1091851

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091851 2024-09-22T10:32:44 Z Jakub_Wozniak Tracks in the Snow (BOI13_tracks) C++17
100 / 100
1957 ms 72592 KB
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
const int maxn = 4003;
typedef long long ll;
int N , M;
string s[maxn];
string SA;
int a , b , c;
vector <pair<char,char>> R;
bool vis[maxn][maxn];
int MAXI = 0;

void pr()
{
    R.push_back({-1,0});
    R.push_back({1,0});
    R.push_back({0,1});
    R.push_back({0,-1});
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> M;
    int i , j , k;
    for(i = 0 ; i <= M+1 ; i++)SA.push_back('.');
    s[0] = SA;
    s[N+1] = SA;


    pr();
    for(i = 1 ; i <= N  ;i++)
    {
        cin >> SA;
        s[i] = '.';
        s[i] += SA;
        s[i].push_back('.');
    }

    priority_queue <pair<int,int>> q;
    pair<int,int> DS;
    q.push({-1,1*maxn+1});
    
    vis[1][1] = 1;

    while(!q.empty())
    {
        DS = q.top();
        c = -DS.first; 
        i = DS.second/maxn;
        j = DS.second-i*maxn;
        q.pop();
        
        MAXI = max(MAXI , c);

        for(k = 0 ; k < R.size() ; k++)
        {
            a = i+R[k].first;
            b = j+R[k].second;
            if(s[a][b] == '.' || vis[a][b])continue;
            vis[a][b] = 1;
            if(s[a][b] == s[i][j]){ q.push({-c,a*maxn+b});}
            else {q.push({-(c+1),a*maxn+b});}
        }
    }

    cout << MAXI << '\n';


    return 0;
}

Compilation message

tracks.cpp: In function 'int main()':
tracks.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<char, char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         for(k = 0 ; k < R.size() ; k++)
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 3160 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 16 ms 3164 KB Output is correct
5 Correct 3 ms 1884 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 3 ms 1720 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 10 ms 1880 KB Output is correct
13 Correct 3 ms 1884 KB Output is correct
14 Correct 4 ms 1980 KB Output is correct
15 Correct 21 ms 3164 KB Output is correct
16 Correct 30 ms 3332 KB Output is correct
17 Correct 13 ms 3164 KB Output is correct
18 Correct 16 ms 3296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 15452 KB Output is correct
2 Correct 77 ms 9524 KB Output is correct
3 Correct 224 ms 55872 KB Output is correct
4 Correct 85 ms 17488 KB Output is correct
5 Correct 125 ms 34896 KB Output is correct
6 Correct 1946 ms 72372 KB Output is correct
7 Correct 6 ms 16220 KB Output is correct
8 Correct 6 ms 15600 KB Output is correct
9 Correct 3 ms 860 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 7 ms 15992 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 77 ms 9624 KB Output is correct
14 Correct 42 ms 6748 KB Output is correct
15 Correct 11 ms 7116 KB Output is correct
16 Correct 39 ms 3804 KB Output is correct
17 Correct 195 ms 18860 KB Output is correct
18 Correct 45 ms 18512 KB Output is correct
19 Correct 80 ms 17712 KB Output is correct
20 Correct 58 ms 16216 KB Output is correct
21 Correct 134 ms 36148 KB Output is correct
22 Correct 130 ms 35016 KB Output is correct
23 Correct 381 ms 29784 KB Output is correct
24 Correct 100 ms 35636 KB Output is correct
25 Correct 211 ms 55980 KB Output is correct
26 Correct 892 ms 45044 KB Output is correct
27 Correct 1528 ms 58156 KB Output is correct
28 Correct 1957 ms 72592 KB Output is correct
29 Correct 1950 ms 64352 KB Output is correct
30 Correct 1879 ms 63144 KB Output is correct
31 Correct 1305 ms 39196 KB Output is correct
32 Correct 1153 ms 57036 KB Output is correct