# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
718887 | 2023-04-05T04:58:38 Z | lam | 최후의 만찬 (IOI12_supper) | C++14 | 컴파일 오류 |
0 ms | 0 KB |
#include "advisor.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; #define ff first #define ss second map<int,int> mp; int a[maxn],pre[maxn],id[maxn],type[maxn]; int xoa[maxn]; void ComputeAdvice(int *C, int N, int K, int M) { int n,k,m; n=N; k=K; for (int i=1; i<=k; i++) a[i]=i-1; for (int i=1; i<=n; i++) a[i+k] = C[i-1]; mp.clear(); m=n+k; for (int i=m; i>=1; i--) { if (!mp[a[i]]) pre[i]=n+1; else pre[i]=mp[a[i]]; mp[a[i]]=i; } fill_n(id,m+1,0); fill_n(type,m+1,0); multiset<ii> ms; for (int i=1; i<=k; i++) ms.insert({pre[i],i}),id[a[i]]=i; for (int i=k+1; i<=m; i++) { if (id[a[i]]!=0) { int x=id[a[i]]; ms.erase(ms.find({pre[x],x})); type[x] = 1; id[a[i]]=i; ms.insert({pre[i],i}); continue; } auto it = ms.end(); it--; xoa[i] = it->ss; ms.erase(it); cerr<<i<<" := xoa "<<a[xoa[i]]<<endl; ms.insert({pre[i],i}); type[xoa[i]] = 2; id[a[xoa[i]]] = 0; id[a[i]] = i; } for (int i=0; i<n; i++) if (id[i]!=0) type[id[i]] = 1; // for (int i=1; i<=m; i++) cerr<<type[i]<<' '; cerr<<endl; for (int i=1; i<=m; i++) if (type[i]==2) WriteAdvice(1); else WriteAdvice(0); }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; typedef pair<int,int> ii; #define ff first #define ss second void Assist(unsigned char *A, int N, int K, int R) { int n,m,k; int type[maxn]; n=N; k=K; m=n+k; multiset<ii> ms; fill_n(type,m+1,0); // for (int i=0; i<R; i++) cerr<<A[i]; cerr<<endl; for (int i=1; i<=k; i++) { char x = A[i-1]; if (x==1) type[i-1] = 2; else type[i-1] = 1; ms.insert({type[i-1],i-1}); }; for (int i=1; i<=n; i++) { int x=GetRequest(); char c = A[k+i-1]; if (type[x]!=0) { ms.erase(ms.find({type[x],x})); int last = type[x]; type[x] = (c==1)+1; if (last==2) type[x] = 2; ms.insert({type[x],x}); } else { auto r = ms.end(); r--; // for (auto j:ms) cerr<<j.ff<<','<<j.ss<<" : "; cerr<<endl; // cerr<<r->ff<<" - "<<r->ss<<endl; PutBack(r->ss); type[r->ss] = 0; ms.erase(r); type[x] = (c==1)+1; ms.insert({type[x],x}); } } }
Compilation message
advisor.cpp:9:7: error: 'maxn' was not declared in this scope 9 | int a[maxn],pre[maxn],id[maxn],type[maxn]; | ^~~~ advisor.cpp:9:17: error: 'maxn' was not declared in this scope 9 | int a[maxn],pre[maxn],id[maxn],type[maxn]; | ^~~~ advisor.cpp:9:26: error: 'maxn' was not declared in this scope 9 | int a[maxn],pre[maxn],id[maxn],type[maxn]; | ^~~~ advisor.cpp:9:37: error: 'maxn' was not declared in this scope 9 | int a[maxn],pre[maxn],id[maxn],type[maxn]; | ^~~~ advisor.cpp:10:9: error: 'maxn' was not declared in this scope 10 | int xoa[maxn]; | ^~~~ advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)': advisor.cpp:14:30: error: 'a' was not declared in this scope 14 | for (int i=1; i<=k; i++) a[i]=i-1; | ^ advisor.cpp:15:30: error: 'a' was not declared in this scope 15 | for (int i=1; i<=n; i++) a[i+k] = C[i-1]; | ^ advisor.cpp:20:17: error: 'a' was not declared in this scope 20 | if (!mp[a[i]]) pre[i]=n+1; | ^ advisor.cpp:20:24: error: 'pre' was not declared in this scope 20 | if (!mp[a[i]]) pre[i]=n+1; | ^~~ advisor.cpp:21:14: error: 'pre' was not declared in this scope 21 | else pre[i]=mp[a[i]]; | ^~~ advisor.cpp:22:12: error: 'a' was not declared in this scope 22 | mp[a[i]]=i; | ^ advisor.cpp:24:12: error: 'id' was not declared in this scope; did you mean 'ii'? 24 | fill_n(id,m+1,0); | ^~ | ii advisor.cpp:25:12: error: 'type' was not declared in this scope; did you mean 'wctype'? 25 | fill_n(type,m+1,0); | ^~~~ | wctype advisor.cpp:27:41: error: 'pre' was not declared in this scope 27 | for (int i=1; i<=k; i++) ms.insert({pre[i],i}),id[a[i]]=i; | ^~~ advisor.cpp:27:50: error: no matching function for call to 'std::multiset<std::pair<int, int> >::insert(<brace-enclosed initializer list>)' 27 | for (int i=1; i<=k; i++) ms.insert({pre[i],i}),id[a[i]]=i; | ^ In file included from /usr/include/c++/10/set:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from advisor.cpp:3: /usr/include/c++/10/bits/stl_multiset.h:502:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 502 | insert(const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:502:32: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'} 502 | insert(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:507:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 507 | insert(value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:507:27: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::multiset<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'} 507 | insert(value_type&& __x) | ~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:532:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 532 | insert(const_iterator __position, const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:532:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_multiset.h:537:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, std::multiset<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 537 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:537:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_multiset.h:551:2: note: candidate: 'template<class _InputIterator> void std::multiset<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 551 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:551:2: note: template argument deduction/substitution failed: advisor.cpp:27:50: note: candidate expects 2 arguments, 1 provided 27 | for (int i=1; i<=k; i++) ms.insert({pre[i],i}),id[a[i]]=i; | ^ In file included from /usr/include/c++/10/set:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from advisor.cpp:3: /usr/include/c++/10/bits/stl_multiset.h:563:7: note: candidate: 'void std::multiset<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 563 | insert(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:563:43: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >' 563 | insert(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ advisor.cpp:27:55: error: 'a' was not declared in this scope 27 | for (int i=1; i<=k; i++) ms.insert({pre[i],i}),id[a[i]]=i; | ^ advisor.cpp:30:16: error: 'a' was not declared in this scope 30 | if (id[a[i]]!=0) | ^ advisor.cpp:33:31: error: 'pre' was not declared in this scope 33 | ms.erase(ms.find({pre[x],x})); | ^~~ advisor.cpp:33:40: error: no matching function for call to 'std::multiset<std::pair<int, int> >::find(<brace-enclosed initializer list>)' 33 | ms.erase(ms.find({pre[x],x})); | ^ In file included from /usr/include/c++/10/set:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from advisor.cpp:3: /usr/include/c++/10/bits/stl_multiset.h:775:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::find(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]' 775 | find(const key_type& __x) | ^~~~ /usr/include/c++/10/bits/stl_multiset.h:775:28: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'} 775 | find(const key_type& __x) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:779:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::const_iterator std::multiset<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>]' 779 | find(const key_type& __x) const | ^~~~ /usr/include/c++/10/bits/stl_multiset.h:779:28: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type&' {aka 'const std::pair<int, int>&'} 779 | find(const key_type& __x) const | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:785:2: note: candidate: 'template<class _Kt> decltype (std::multiset<_Key, _Compare, _Alloc>::iterator{((std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::multiset<_Key, _Compare, _Alloc>::find(const _Kt&) [with _Kt = _Kt; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 785 | find(const _Kt& __x) | ^~~~ /usr/include/c++/10/bits/stl_multiset.h:785:2: note: template argument deduction/substitution failed: advisor.cpp:33:40: note: couldn't deduce template parameter '_Kt' 33 | ms.erase(ms.find({pre[x],x})); | ^ In file included from /usr/include/c++/10/set:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from advisor.cpp:3: /usr/include/c++/10/bits/stl_multiset.h:791:2: note: candidate: 'template<class _Kt> decltype (std::multiset<_Key, _Compare, _Alloc>::const_iterator{((const std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::multiset<_Key, _Compare, _Alloc>::find(const _Kt&) const [with _Kt = _Kt; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 791 | find(const _Kt& __x) const | ^~~~ /usr/include/c++/10/bits/stl_multiset.h:791:2: note: template argument deduction/substitution failed: advisor.cpp:33:40: note: couldn't deduce template parameter '_Kt' 33 | ms.erase(ms.find({pre[x],x})); | ^ advisor.cpp:36:33: error: no matching function for call to 'std::multiset<std::pair<int, int> >::insert(<brace-enclosed initializer list>)' 36 | ms.insert({pre[i],i}); | ^ In file included from /usr/include/c++/10/set:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from advisor.cpp:3: /usr/include/c++/10/bits/stl_multiset.h:502:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 502 | insert(const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:502:32: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'} 502 | insert(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:507:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 507 | insert(value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:507:27: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::multiset<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'} 507 | insert(value_type&& __x) | ~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_multiset.h:532:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 532 | insert(const_iterator __position, const value_type& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:532:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_multiset.h:537:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(std::multiset<_Key, _Compare, _Alloc>::const_iterator, std::multiset<_Key, _Compare, _Alloc>::value_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>]' 537 | insert(const_iterator __position, value_type&& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:537:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_multiset.h:551:2: note: candidate: 'template<class _InputIterator> void std::multiset<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 551 | insert(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:551:2: note: template argument deduction/substitution failed: advisor.cpp:36:33: note: candidate expects 2 arguments, 1 provided 36 | ms.insert({pre[i],i}); | ^ In file included from /usr/include/c++/10/set:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87, from advisor.cpp:3: /usr/include/c++/10/bits/stl_multiset.h:563:7: note: candidate: 'void std::multiset<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 563 | insert(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/10/bits/stl_multiset.h:563:43: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >' 563 | insert(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ advisor.cpp:40:9: error: 'xoa' was not declared in this scope 40 | xoa[i] = it->ss; | ^~~ advisor.cpp:42:30: error: 'a' was not declared in this scope 42 | cerr<<i<<" := xoa "<<a[xoa[i]]<<endl; | ^ advisor.cpp:43:20: error: 'pre' was n