제출 #1172691

#제출 시각아이디문제언어결과실행 시간메모리
1172691jadai007악어의 지하 도시 (IOI11_crocodile)C++20
컴파일 에러
0 ms0 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; /*#define MAX_N 50000 #define MAX_M 10000000 static int N, M; static int R[MAX_M][2]; static int L[MAX_M]; static int K; static int P[MAX_N]; static int solution; inline void my_assert(int e) {if (!e) abort();} void read_input() { int i; my_assert(3==scanf("%d %d %d",&N,&M,&K)); for(i=0; i<M; i++) my_assert(3==scanf("%d %d %d",&R[i][0],&R[i][1],&L[i])); for(i=0; i<K; i++) my_assert(1==scanf("%d",&P[i])); my_assert(1==scanf("%d",&solution)); } */ int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){ priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; vector<int> vc[N]; int dis[N]; for(int i = 0; i < N; ++i) dis[i] = 1e9 + 7; for(int i = 0; i < M; ++i) vc[R[i][0]].emplace_back(R[i][1], L[i]), vc[R[i][1]].emplace_back(R[i][0], L[i]); dis[0] = 0; pq.emplace(0, 0); while(!pq.empty()){ int u = pq.top().second, cnt = pq.top().first; pq.pop(); if(dis[u] < cnt) continue; for(auto x:vc[u]){ int v = x.first, w = x.second; if(dis[v] > w + cnt){ dis[v] = w + cnt; pq.emplace(dis[v], v); } } } int ans = -1; for(int i = 0; i < K; ++i){ if(dis[i] == 1e9 + 7) continue; ans = max(ans, dis[i]); } return ans; } /* int main() { int ans; read_input(); ans = travel_plan(N,M,R,L,K,P); if(ans==solution) printf("Correct.\n"); else printf("Incorrect. Returned %d, Expected %d.\n",ans,solution); return 0; }*/

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

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:44:23: error: request for member 'first' in 'x', which is of non-class type 'int'
   44 |             int v = x.first, w = x.second;
      |                       ^~~~~
crocodile.cpp:45:25: error: 'w' was not declared in this scope
   45 |             if(dis[v] > w + cnt){
      |                         ^
In file included from /usr/include/c++/11/ext/alloc_traits.h:34,
                 from /usr/include/c++/11/bits/basic_string.h:40,
                 from /usr/include/c++/11/string:55,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from crocodile.cpp:2:
/usr/include/c++/11/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {int&, int&}; _Tp = int; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<int>]':
/usr/include/c++/11/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&]'
crocodile.cpp:36:56:   required from here
/usr/include/c++/11/bits/alloc_traits.h:518:28: error: no matching function for call to 'construct_at(int*&, int&, int&)'
  518 |           std::construct_at(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/stl_iterator.h:85,
                 from /usr/include/c++/11/bits/stl_algobase.h:67,
                 from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from crocodile.cpp:2:
/usr/include/c++/11/bits/stl_construct.h:94:5: note: candidate: 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)'
   94 |     construct_at(_Tp* __location, _Args&&... __args)
      |     ^~~~~~~~~~~~
/usr/include/c++/11/bits/stl_construct.h:94:5: note:   template argument deduction/substitution failed:
/usr/include/c++/11/bits/stl_construct.h: In substitution of 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = int; _Args = {int&, int&}]':
/usr/include/c++/11/bits/alloc_traits.h:518:21:   required from 'static constexpr void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {int&, int&}; _Tp = int; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<int>]'
/usr/include/c++/11/bits/vector.tcc:115:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&]'
crocodile.cpp:36:56:   required from here
/usr/include/c++/11/bits/stl_construct.h:96:17: error: new initializer expression list treated as compound expression [-fpermissive]
   96 |     -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~