제출 #1200962

#제출 시각아이디문제언어결과실행 시간메모리
1200962abckefjiMecho (IOI09_mecho)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>

using namespace std;
 
#define ll long long
#define pi pair<int, int>
#define ti tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

vector<vector<char>> grid;
vector<vector<int>> t;

vector<pi> direction={{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int n;
ll s;
int si=-1, sj=-1;

bool bfs(ll mid) {
    vector<vector<ll>> step(n, vector<ll>(n, -1));
    queue<pi> nq;
    
    step[si][sj]=s*mid;
    nq.push({si, sj});
    
    while(nq.size()) {
        auto [i, j]=nq.front(); nq.pop();

        if(grid[i][j]=='D') return true;
        
        for(auto &[di, dj]: direction) {
            int ni=i+di;
            int nj=j+dj;
            
            if(ni>=0 && nj>=0 && ni<n && nj<n && 1LL*(step[i][j]+1)/s<t[ni][nj] && grid[ni][nj]!='T' && step[ni][nj]==-1) {
                step[ni][nj]=step[i][j]+1;
                nq.push({ni, nj});
            }
        }
    }
    
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> s;
    
    grid.resize(n, vector<char>(n));
    t.resize(n, vector<ll>(n, LLONG_MAX));
    
    queue<pi> q;
    
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            cin >> grid[i][j];
            if(grid[i][j]=='H') {
                q.push({i, j});
                t[i][j]=0;
            } else if(grid[i][j]=='M') {
                si=i;
                sj=j;
            }
        }
    }

    
    while(q.size()) {
        auto [i, j]=q.front(); q.pop();
        
        for(auto &[di, dj]: direction) {
            int ni=i+di;
            int nj=j+dj;
            
            if(ni>=0 && nj>=0 && ni<n && nj<n && t[ni][nj]==INT_MAX && grid[ni][nj]!='T') {
                t[ni][nj]=t[i][j]+1;
                q.push({ni, nj});
            }
        }
    }
    
//    for(int i=0; i<n; i++) {
//        for(int j=0; j<n; j++) {
//            if(t[i][j]==INT_MAX) cout << "- ";
//            else cout << t[i][j] << " ";
//        }
//        cout << '\n';
//    }
    
    ll l=0, r=INT_MAX;
    
    while(l<r) {
        ll mid=(l+r+1)/2;
        
        if(bfs(mid)) {
            l=mid;
        } else {
            r=mid-1;
        }
    }
    
    cout << l;
    
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

mecho.cpp: In function 'int main()':
mecho.cpp:52:13: error: no matching function for call to 'std::vector<std::vector<int> >::resize(int&, std::vector<long long int>)'
   52 |     t.resize(n, vector<ll>(n, LLONG_MAX));
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from mecho.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:937:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
  937 |       resize(size_type __new_size)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:937:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/11/bits/stl_vector.h:957:7: note: candidate: 'void std::vector<_Tp, _Alloc>::resize(std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::vector<int>]'
  957 |       resize(size_type __new_size, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/11/bits/stl_vector.h:957:54: note:   no known conversion for argument 2 from 'std::vector<long long int>' to 'const value_type&' {aka 'const std::vector<int>&'}
  957 |       resize(size_type __new_size, const value_type& __x)
      |                                    ~~~~~~~~~~~~~~~~~~^~~