# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
718890 | lam | Last supper (IOI12_supper) | C++14 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]=m+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;
int num=0;
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);
ms.insert({pre[i],i});
type[xoa[i]] = 2;
id[a[xoa[i]]] = 0;
id[a[i]] = i;
num++;
}
// cerr<<num<<"!!"<<endl;
for (int i=0; i<n; i++) if (id[i]!=0) type[id[i]] = 2;
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=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;
ms.insert({type[x],x});
}
else
{
auto r = ms.end(); r--;
PutBack(r->ss);
type[r->ss] = 0;
ms.erase(r);
type[x] = (c==1)+1;
ms.insert({type[x],x});
}
}
}
Compilation message (stderr)
advisor.cpp:8:7: error: 'maxn' was not declared in this scope 8 | int a[maxn],pre[maxn],id[maxn],type[maxn]; | ^~~~ advisor.cpp:8:17: error: 'maxn' was not declared in this scope 8 | int a[maxn],pre[maxn],id[maxn],type[maxn]; | ^~~~ advisor.cpp:8:26: error: 'maxn' was not declared in this scope 8 | int a[maxn],pre[maxn],id[maxn],type[maxn]; | ^~~~ advisor.cpp:8:37: error: 'maxn' was not declared in this scope 8 | int a[maxn],pre[maxn],id[maxn],type[maxn]; | ^~~~ advisor.cpp:9:9: error: 'maxn' was not declared in this scope 9 | int xoa[maxn]; | ^~~~ advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)': advisor.cpp:13:30: error: 'a' was not declared in this scope 13 | for (int i=1; i<=k; i++) a[i]=i-1; | ^ advisor.cpp:14:30: error: 'a' was not declared in this scope 14 | for (int i=1; i<=n; i++) a[i+k] = C[i-1]; | ^ advisor.cpp:19:17: error: 'a' was not declared in this scope 19 | if (!mp[a[i]]) pre[i]=m+1; | ^ advisor.cpp:19:24: error: 'pre' was not declared in this scope 19 | if (!mp[a[i]]) pre[i]=m+1; | ^~~ advisor.cpp:20:14: error: 'pre' was not declared in this scope 20 | else pre[i]=mp[a[i]]; | ^~~ advisor.cpp:21:12: error: 'a' was not declared in this scope 21 | mp[a[i]]=i; | ^ advisor.cpp:23:12: error: 'id' was not declared in this scope; did you mean 'ii'? 23 | fill_n(id,m+1,0); | ^~ | ii advisor.cpp:24:12: error: 'type' was not declared in this scope; did you mean 'wctype'? 24 | fill_n(type,m+1,0); | ^~~~ | wctype advisor.cpp:26:41: error: 'pre' was not declared in this scope 26 | for (int i=1; i<=k; i++) ms.insert({pre[i],i}),id[a[i]]=i; | ^~~ advisor.cpp:26:50: error: no matching function for call to 'std::multiset<std::pair<int, int> >::insert(<brace-enclosed initializer list>)' 26 | 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:2: /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:26:50: note: candidate expects 2 arguments, 1 provided 26 | 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:2: /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:26:55: error: 'a' was not declared in this scope 26 | 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:2: /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:2: /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:2: /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:2: /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:20: error: 'pre' was not declared in this scope 42 | ms.insert({pre[i],i}); | ^~~ advisor.cpp:42:29: error: no matching function for call to assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)': assistant.cpp:32:17: warning: unused variable 'last' [-Wunused-variable] 32 | int last = type[x]; | ^~~~