# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
349742 | 2021-01-18T09:50:02 Z | Bill_00 | The Potion of Great Power (CEOI20_potion) | C++14 | 컴파일 오류 |
0 ms | 0 KB |
#include <bits/stdc++.h> #define N 200000 #define M 100000 #define pb push_back #define ff first #define ss second using namespace std; int h[M],n; vector<int>v[M]; int cnt[N]; int q[M][2]; vector<pair<int,bool> >day[N]; void init(int nn,int d, int H[]){ n=nn; for(int i=0;i<n;i++) h[i]=H[i]; } void curseChanges(int u, int A[], int B[]){ for(int i=1;i<=u;i++){ cnt[A[i-1]]++; cnt[B[i-1]]++; } for(int i=0;i<n;i++){ v[i].resize(cnt[i]); cnt[i]=0; } for(int i=1;i<=u;i++){ q[i][0]=cnt[A[i-1]]; q[i][1]=cnt[B[i-1]]; cnt[A[i-1]]++; cnt[B[i-1]]++; } for(int i=0;i<n;i++) cnt[i]=0; for(int i=1;i<=u;i++){ int a=A[i-1],b=B[i-1]; day[a].pb({i,0}); day[b].pb({i,1}); if(cnt[a]==0){ v[a][cnt[a]].pb(b); } else{ bool flag=0; for(int j:v[a][cnt[a]-1]){ if(j==b){ flag=1; continue; } v[a][cnt[a]].pb(j); } if(flag==0) v[a][cnt[a]].pb(b); } if(cnt[b]==0){ v[b][cnt[b]].pb(a); } else{ bool flag=0; for(int j:v[b][cnt[b]-1]){ if(j==a){ flag=1; continue; } v[b][cnt[b]].pb(j); } if(flag==0) v[b][cnt[b]].pb(a); } cnt[a]++; cnt[b]++; } } int question(int x, int y, int z) { int ans=1e9; int id=upper_bound(day[x].begin(),day[x].end(),z)-day[x].begin(); --id; int e=day[x].size()-1; if(id<0 || id>e){ return ans; } int a=q[day[x][id].ff][day[x][id].ss]; id=upper_bound(day[y].begin(),day[y].end(),z)-day[y].begin(); --id; e=day[y].size()-1; if(id<0 || id>e){ return ans; } int b=q[day[y][id].ff][day[y][id].ss]; // cout << a << ' ' << b << '\n'; if(v[x][a].size()==0 || v[y][b].size()==0){ return ans; } vector<int>xx,yy; for(int V:v[y][b]){ yy.pb(h[V]); } sort(yy.begin(),yy.end()); for(int U:v[x][a]){ int id=lower_bound(yy.begin(),yy.end(),h[U])-yy.begin(); ans=min(ans,abs(h[U]-yy[max(0,id-1)])); int r=yy.size()-1; ans=min(ans,abs(yy[min(id,r)]-h[U])); } return ans; }
Compilation message
potion.cpp: In function 'void curseChanges(int, int*, int*)': potion.cpp:4:12: error: request for member 'push_back' in 'v[a].std::vector<int>::operator[](((std::vector<int>::size_type)cnt[a]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ potion.cpp:39:17: note: in expansion of macro 'pb' 39 | v[a][cnt[a]].pb(b); | ^~ potion.cpp:43:27: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 43 | for(int j:v[a][cnt[a]-1]){ | ^ | std::begin In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95, from potion.cpp:1: /usr/include/c++/9/valarray:1224:5: note: 'std::begin' declared here 1224 | begin(const valarray<_Tp>& __va) | ^~~~~ potion.cpp:43:27: error: 'end' was not declared in this scope; did you mean 'std::end'? 43 | for(int j:v[a][cnt[a]-1]){ | ^ | std::end In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95, from potion.cpp:1: /usr/include/c++/9/valarray:1244:5: note: 'std::end' declared here 1244 | end(const valarray<_Tp>& __va) | ^~~ potion.cpp:4:12: error: request for member 'push_back' in 'v[a].std::vector<int>::operator[](((std::vector<int>::size_type)cnt[a]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ potion.cpp:48:18: note: in expansion of macro 'pb' 48 | v[a][cnt[a]].pb(j); | ^~ potion.cpp:4:12: error: request for member 'push_back' in 'v[a].std::vector<int>::operator[](((std::vector<int>::size_type)cnt[a]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ potion.cpp:50:29: note: in expansion of macro 'pb' 50 | if(flag==0) v[a][cnt[a]].pb(b); | ^~ potion.cpp:4:12: error: request for member 'push_back' in 'v[b].std::vector<int>::operator[](((std::vector<int>::size_type)cnt[b]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ potion.cpp:53:17: note: in expansion of macro 'pb' 53 | v[b][cnt[b]].pb(a); | ^~ potion.cpp:57:27: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 57 | for(int j:v[b][cnt[b]-1]){ | ^ | std::begin In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95, from potion.cpp:1: /usr/include/c++/9/valarray:1224:5: note: 'std::begin' declared here 1224 | begin(const valarray<_Tp>& __va) | ^~~~~ potion.cpp:57:27: error: 'end' was not declared in this scope; did you mean 'std::end'? 57 | for(int j:v[b][cnt[b]-1]){ | ^ | std::end In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95, from potion.cpp:1: /usr/include/c++/9/valarray:1244:5: note: 'std::end' declared here 1244 | end(const valarray<_Tp>& __va) | ^~~ potion.cpp:4:12: error: request for member 'push_back' in 'v[b].std::vector<int>::operator[](((std::vector<int>::size_type)cnt[b]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ potion.cpp:62:18: note: in expansion of macro 'pb' 62 | v[b][cnt[b]].pb(j); | ^~ potion.cpp:4:12: error: request for member 'push_back' in 'v[b].std::vector<int>::operator[](((std::vector<int>::size_type)cnt[b]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ potion.cpp:64:29: note: in expansion of macro 'pb' 64 | if(flag==0) v[b][cnt[b]].pb(a); | ^~ potion.cpp: In function 'int question(int, int, int)': potion.cpp:89:13: error: request for member 'size' in 'v[x].std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 89 | if(v[x][a].size()==0 || v[y][b].size()==0){ | ^~~~ potion.cpp:89:34: error: request for member 'size' in 'v[y].std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 89 | if(v[x][a].size()==0 || v[y][b].size()==0){ | ^~~~ potion.cpp:93:18: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 93 | for(int V:v[y][b]){ | ^ | std::begin In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95, from potion.cpp:1: /usr/include/c++/9/valarray:1224:5: note: 'std::begin' declared here 1224 | begin(const valarray<_Tp>& __va) | ^~~~~ potion.cpp:93:18: error: 'end' was not declared in this scope; did you mean 'std::end'? 93 | for(int V:v[y][b]){ | ^ | std::end In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95, from potion.cpp:1: /usr/include/c++/9/valarray:1244:5: note: 'std::end' declared here 1244 | end(const valarray<_Tp>& __va) | ^~~ potion.cpp:97:18: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 97 | for(int U:v[x][a]){ | ^ | std::begin In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95, from potion.cpp:1: /usr/include/c++/9/valarray:1224:5: note: 'std::begin' declared here 1224 | begin(const valarray<_Tp>& __va) | ^~~~~ potion.cpp:97:18: error: 'end' was not declared in this scope; did you mean 'std::end'? 97 | for(int U:v[x][a]){ | ^ | std::end In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:95, from potion.cpp:1: /usr/include/c++/9/valarray:1244:5: note: 'std::end' declared here 1244 | end(const valarray<_Tp>& __va) | ^~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:71, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = const int; _Iterator = __gnu_cxx::__normal_iterator<std::pair<int, bool>*, std::vector<std::pair<int, bool> > >]': /usr/include/c++/9/bits/stl_algo.h:2051:14: required from '_ForwardIterator std::__upper_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<std::pair<int, bool>*, std::vector<std::pair<int, bool> > >; _Tp = int; _Compare = __gnu_cxx::__ops::_Val_less_iter]' /usr/include/c++/9/bits/stl_algo.h:2085:32: required from '_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = __gnu_cxx::__normal_iterator<std::pair<int, bool>*, std::vector<std::pair<int, bool> > >; _Tp = int]' potion.cpp:73:50: required from here /usr/include/c++/9/bits/predefined_ops.h:90:22: error: no match for 'operator<' (operand types are 'const int' and 'std::pair<int, bool>') 90 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:67, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/stl_iterator.h:915:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)' 915 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/stl_iterator.h:915:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/bits/stl_algobase.h:71, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/predefined_ops.h:90:22: note: mismatched types 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' and 'const int' 90 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/9/bits/stl_algobase.h:67, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/stl_iterator.h:922:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)' 922 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/stl_iterator.h:922:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/bits/stl_algobase.h:71, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/predefined_ops.h:90:22: note: mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'const int' 90 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/9/regex:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110, from potion.cpp:1: /usr/include/c++/9/bits/regex.h:1048:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)' 1048 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/9/bits/regex.h:1048:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/bits/stl_algobase.h:71, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/predefined_ops.h:90:22: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const int' 90 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/9/regex:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110, from potion.cpp:1: /usr/include/c++/9/bits/regex.h:1124:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&)' 1124 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/regex.h:1124:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/bits/stl_algobase.h:71, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/predefined_ops.h:90:22: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'const int' 90 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/9/regex:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110, from potion.cpp:1: /usr/include/c++/9/bits/regex.h:1198:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1198 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/regex.h:1198:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/bits/stl_algobase.h:71, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/predefined_ops.h:90:22: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const int' 90 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/9/regex:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110, from potion.cpp:1: /usr/include/c++/9/bits/regex.h:1272:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&)' 1272 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/regex.h:1272:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/bits/stl_algobase.h:71, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/predefined_ops.h:90:22: note: 'std::pair<int, bool>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 90 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/9/regex:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110, from potion.cpp:1: /usr/include/c++/9/bits/regex.h:1346:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1346 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/9/bits/regex.h:1346:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/9/bits/stl_algobase.h:71, from /usr/include/c++/9/bits/char_traits.h:39, from /usr/include/c++/9/ios:40, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/c++/9/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54, from potion.cpp:1: /usr/include/c++/9/bits/predefined_ops.h:90:22: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'const int' 90 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/9/regex:62, from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:110, from potion.cpp:1: /usr/include/c++/9/bits/regex.h:1421:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::val