제출 #290130

#제출 시각아이디문제언어결과실행 시간메모리
290130REALITYNB경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "race.h" #define pb push_back #define int long long #define mp make_pair #define pii pair<int,int> #define F first #define S second using namespace std; int n , k ; const int mxn = 2e5+1 ; vector<pii> adj[mxn] ; vector<int> sz(mxn) , w(mxn) ,h(mxn) ; void sub(int a , int p){ sz[a]=1 ; if(p!=-1) h[a]=h[p]+1 ; for(pii& x : adj[a]){ if(x.F==p) continue ; w[x.F]=w[a]+x.S ; sub(x.F,a) ; sz[a]+=sz[x.F] ; } } int mn = 1e9 ; vector<int> p[mxn] ; map<int,multiset<int>> cnt ; void dfs(int a , int pp , int keep){ int bigchild = -1 , mx = -1 ; for(pii& y : adj[a]){ int x = y.F ; if(x==pp) continue ; if(sz[x]>mx){ mx=sz[x] ; bigchild= x ; } } for(pii& y : adj[a]){ int x = y.F ; if(x==pp||x==bigchild) continue ; dfs(x,a,0) ; } if(bigchild!=-1){ dfs(bigchild,a,1) ; swap(p[bigchild],p[a]) ; // p[bigchild].swap(p[a]) ; } p[a].push_back(a) ; int target = k+2*w[a] ; if(cnt.count(target-w[a])) mn = min(mn,*(cnt[target-w[a]].begin())-h[a]) ; cnt[w[a]].insert(h[a]) ; for(pii& y : adj[a]){ if(y.F==pp||y.F==bigchild) continue ; for(int& x : p[y.F]){ if(cnt.count(target-w[x])) mn = min(*(cnt[target-w[x]].begin())+h[x]-h[a]*2,mn) ; p[a].pb(x) ; } for(int& x :p[y.F]) cnt[w[a]].insert(h[x]) ; } if(keep==0){ for(int& x: p[a]){ cnt[w[x]].erase(cnt[w[x]].find(h[x])) ; if(cnt[w[x]].empty()) cnt.erase(cnt.find(w[x])) ; } } } int solve(){ sub(1,-1) ; dfs(1,-1,1) ; if(mn==1e9) return -1; return mn ; } int best_path(int N , int K , int H[][2] , int L[]){ n = N ; k = K ; cnt.erase(cnt.begin(),cnt.end()) ; for(int& x : h) x = 0 ; for(int& x : w) x = 0 ; for(vector<int>& x : p) x.erase(x.begin(),x.end()) ; for(int i=0;i<=n;i++) cnt[i].erase(cnt[i].begin(),cnt.end()) ; if(n>100 ) return 0; for(int i=0;i<n;i++){ adj[H[i][0]].push_back(mp(H[i][1],L[i])); adj[H[i][1]].push_back(mp(H[i][0],L[i])) ; } return solve() ; }

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

race.cpp: In function 'long long int best_path(long long int, long long int, long long int (*)[2], long long int*)':
race.cpp:79:64: error: no matching function for call to 'std::multiset<long long int>::erase(std::multiset<long long int>::iterator, std::map<long long int, std::multiset<long long int> >::iterator)'
   79 |     for(int i=0;i<=n;i++) cnt[i].erase(cnt[i].begin(),cnt.end()) ;
      |                                                                ^
In file included from /usr/include/c++/9/set:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:87,
                 from race.cpp:1:
/usr/include/c++/9/bits/stl_multiset.h:639:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::erase(std::multiset<_Key, _Compare, _Alloc>::const_iterator) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<long long int>; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<long long int>]'
  639 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/9/bits/stl_multiset.h:639:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_multiset.h:669:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::size_type std::multiset<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; std::multiset<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::multiset<_Key, _Compare, _Alloc>::key_type = long long int]'
  669 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/9/bits/stl_multiset.h:669:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_multiset.h:691:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::erase(std::multiset<_Key, _Compare, _Alloc>::const_iterator, std::multiset<_Key, _Compare, _Alloc>::const_iterator) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<long long int>; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<long long int>]'
  691 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/9/bits/stl_multiset.h:691:52: note:   no known conversion for argument 2 from 'std::map<long long int, std::multiset<long long int> >::iterator' {aka 'std::_Rb_tree_iterator<std::pair<const long long int, std::multiset<long long int> > >'} to 'std::multiset<long long int>::const_iterator' {aka 'std::_Rb_tree_const_iterator<long long int>'}
  691 |       erase(const_iterator __first, const_iterator __last)
      |                                     ~~~~~~~~~~~~~~~^~~~~~