제출 #674611

#제출 시각아이디문제언어결과실행 시간메모리
674611sudheerays123Mecho (IOI09_mecho)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll long long int const ll N = 800+5 , INF = 1e18 , MOD = 1e9+7; ll sx,sy,ex,ey; vector<ll> dx = {0,0,-1,1}; vector<ll> dy = {-1,1,0,0}; vector<vector<ll>> bee(N,vector<ll>(N,INF)); vector<vector<char>> grid(N,vector<char>(N)); ll n,s; bool check(ll start){ vector<vector<ll>> dist(n+5,vector<ll>(n+5,INF)); dist[sx][sy] = start; queue<pair<ll,ll>> q; q.push(make_pair(sx,sy)); while(!q.empty()){ ll a = q.front().first; ll b = q.front().second; q.pop(); for(ll t = 0; t <= 3; t++){ ll x = a+dx[t]; ll y = b+dy[t]; if(x < 1 || x > n || y < 1 || y > n || grid[x][y] == 'T' || grid[x][y] == 'H') continue; if(dist[x][y] != INF) continue; ll d = dist[a][b]+1; ll c = start+ceil(double(d-start)/double(s)); if(c <= bee[x][y]){ dist[x][y] = d; q.push(make_pair(x,y)); } } } return (dist[ex][ey] != INF); } void solve(){ cin >> n >> s; queue<pair<ll,ll>> q; for(ll i = 1; i <= n; i++){ for(ll j = 1; j <= n; j++){ cin >> grid[i][j]; if(grid[i][j] == 'M'){ sx = i; sy = j; } else if(grid[i][j] == 'H'){ q.push(make_tuple(i,j)); bee[i][j] = 0; } else if(grid[i][j] == 'D'){ ex = i; ey = j; } } } while(!q.empty()){ ll a = q.front().first; ll b = q.front().second; q.pop(); for(ll t = 0; t <= 3; t++){ ll x = a+dx[t]; ll y = b+dy[t]; if(x < 1 || x > n || y < 1 || y > n || grid[x][y] == 'D' || grid[x][y] == 'T') continue; if(bee[x][y] != INF) continue; bee[x][y] = bee[a][b]+1; q.push(make_tuple(x,y)); } } ll low = 0 , high = bee[sx][sy]-1; ll ans = INF; while(low <= high){ ll mid = (low+high)/2; if(check(mid)){ ans = mid; low = mid+1; } else high = mid-1; } if(ans == INF) ans = -1; cout << ans; } int main(){ fast; ll tc = 1; // cin >> tc; while(tc--) solve(); return 0; }

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

mecho.cpp: In function 'void solve()':
mecho.cpp:62:27: error: no matching function for call to 'std::queue<std::pair<long long int, long long int> >::push(std::tuple<long long int, long long int>)'
   62 |     q.push(make_tuple(i,j));
      |                           ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from mecho.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from 'std::tuple<long long int, long long int>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from 'std::tuple<long long int, long long int>' to 'std::queue<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
mecho.cpp:85:26: error: no matching function for call to 'std::queue<std::pair<long long int, long long int> >::push(std::tuple<long long int, long long int>)'
   85 |    q.push(make_tuple(x,y));
      |                          ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from mecho.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from 'std::tuple<long long int, long long int>' to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from 'std::tuple<long long int, long long int>' to 'std::queue<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~