# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58830 | 2018-07-19T15:33:20 Z | MatheusLealV | Last supper (IOI12_supper) | C++17 | Compilation error |
0 ms | 0 KB |
#include <bits/stdc++.h> #include "advisor.h" #define inf 1000000000 #define maxn 100050 #define f first #define s second using namespace std; typedef pair<int, int> pii; int n, k, m, sz, t = 0, id = 0; void write(int x) { for(int i = 0; i <= sz; i++) { t++; //cout<<"QTD "<<t<<"\n"; if(x & (1<<i)) { WriteAdvice(1); //cout<<"ADD 1\n"; } else { WriteAdvice(0); //cout<<"ADD 0\n"; } id ++; } } void ComputeAdvice(int *C, int N, int K, int M) { n = N, k = K, m = M; sz = log2(n); for(int i = 0; i < N; i++) write(C[i]); }
#include <bits/stdc++.h> #include "assistant.h" #define maxnn 1000050 #define f first #define s second using namespace std; typedef pair<int, int> pii; vector<int> order; set<int> pos[maxnn]; set< pii > inside; void simule(int N, int *C) { for(int i = 0; i < k; i++) { int prox = inf; if(!pos[i].empty()) prox = *(pos[i].begin()); inside.insert({-prox, i}); } //vector<int> opt_order; set<int> dentro; for(int i = 0; i < k; i++) dentro.insert(i); for(int i = 0; i < N; i++) { int tempo = (*(inside.begin())).f, x = (*(inside.begin())).s; int A = GetRequest(); PutBack(x); pos[x].erase(-tempo); int prox = inf, y = C[i]; pos[y].erase(-i); if(!pos[y].empty()) prox = *(pos[y].begin()); if(inside.count({-prox, y})) continue; inside.erase({tempo, x}); inside.insert({-prox, y}); //cout<<"REMOVENDO "<<x<<" "<<tempo<<"\n"; //cout<<"QTD "<<t<<"\n"; //write(x); //cout<<"REMOVE "<<x<<" "<<"ADD "<<y<<"\n"; //cout<<"COLOCANDO "<<y<<" "<<prox<<"\n"; } } void Assist(unsigned char *A, int N, int K, int R) { int n = N, k = K, r = R, sz = (log2(n)); int C[maxnn]; for(int i = 0, l = 0; i < R; i += sz + 1) { int num = 0, id = 0; for(int j = i ; j <= i + sz; j++, id ++) { if(A[j] == 1) num += (1<<id); } C[l] = num; l++; } simule(N, C); }
Compilation message
assistant.cpp: In function 'void simule(int, int*)': assistant.cpp:17:21: error: 'k' was not declared in this scope for(int i = 0; i < k; i++) ^ assistant.cpp:19:14: error: 'inf' was not declared in this scope int prox = inf; ^~~ assistant.cpp:19:14: note: suggested alternative: 'ynf' int prox = inf; ^~~ ynf assistant.cpp:30:21: error: 'k' was not declared in this scope for(int i = 0; i < k; i++) dentro.insert(i); ^ assistant.cpp:42:14: error: 'inf' was not declared in this scope int prox = inf, y = C[i]; ^~~ assistant.cpp:42:14: note: suggested alternative: 'ynf' int prox = inf, y = C[i]; ^~~ ynf assistant.cpp:44:7: error: 'y' was not declared in this scope pos[y].erase(-i); ^ assistant.cpp:48:29: error: no matching function for call to 'std::set<std::pair<int, int> >::count(<brace-enclosed initializer list>)' if(inside.count({-prox, y})) continue; ^ In file included from /usr/include/c++/7/set:61:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87, from assistant.cpp:1: /usr/include/c++/7/bits/stl_set.h:738:7: note: candidate: std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(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::set<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::set<_Key, _Compare, _Alloc>::key_type = std::pair<int, int>] count(const key_type& __x) const ^~~~~ /usr/include/c++/7/bits/stl_set.h:738:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type& {aka const std::pair<int, int>&}' /usr/include/c++/7/bits/stl_set.h:744:2: note: candidate: template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(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> >] count(const _Kt& __x) const ^~~~~ /usr/include/c++/7/bits/stl_set.h:744:2: note: template argument deduction/substitution failed: assistant.cpp:48:29: note: couldn't deduce template parameter '_Kt' if(inside.count({-prox, y})) continue; ^ assistant.cpp:52:27: error: no matching function for call to 'std::set<std::pair<int, int> >::insert(<brace-enclosed initializer list>)' inside.insert({-prox, y}); ^ In file included from /usr/include/c++/7/set:61:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87, from assistant.cpp:1: /usr/include/c++/7/bits/stl_set.h:499:7: note: candidate: std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_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> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>] insert(const value_type& __x) ^~~~~~ /usr/include/c++/7/bits/stl_set.h:499:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}' /usr/include/c++/7/bits/stl_set.h:508:7: note: candidate: std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(std::set<_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> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Key>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>] insert(value_type&& __x) ^~~~~~ /usr/include/c++/7/bits/stl_set.h:508:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}' /usr/include/c++/7/bits/stl_set.h:536:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_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::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>] insert(const_iterator __position, const value_type& __x) ^~~~~~ /usr/include/c++/7/bits/stl_set.h:536:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/7/bits/stl_set.h:541:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_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::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::value_type = std::pair<int, int>] insert(const_iterator __position, value_type&& __x) ^~~~~~ /usr/include/c++/7/bits/stl_set.h:541:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/7/bits/stl_set.h:556:2: note: candidate: template<class _InputIterator> void std::set<_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> >] insert(_InputIterator __first, _InputIterator __last) ^~~~~~ /usr/include/c++/7/bits/stl_set.h:556:2: note: template argument deduction/substitution failed: assistant.cpp:52:27: note: candidate expects 2 arguments, 1 provided inside.insert({-prox, y}); ^ In file included from /usr/include/c++/7/set:61:0, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87, from assistant.cpp:1: /usr/include/c++/7/bits/stl_set.h:568:7: note: candidate: void std::set<_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> >] insert(initializer_list<value_type> __l) ^~~~~~ /usr/include/c++/7/bits/stl_set.h:568:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >' /usr/include/c++/7/bits/stl_set.h:588:7: note: candidate: std::set<_Key, _Compare, _Alloc>::insert_return_type std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::node_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::insert_return_type = std::_Node_insert_return<std::_Rb_tree_const_iterator<std::pair<int, int> >, std::_Node_handle<std::pair<int, int>, std::pair<int, int>, std::allocator<std::_Rb_tree_node<std::pair<int, int> > > > >; std::set<_Key, _Compare, _Alloc>::node_type = std::_Node_handle<std::pair<int, int>, std::pair<int, int>, std::allocator<std::_Rb_tree_node<std::pair<int, int> > > >] insert(node_type&& __nh) ^~~~~~ /usr/include/c++/7/bits/stl_set.h:588:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<int, int> >::node_type&& {aka std::_Node_handle<std::pair<int, int>, std::pair<int, int>, std::allocator<std::_Rb_tree_node<std::pair<int, int> > > >&&}' /usr/include/c++/7/bits/stl_set.h:593:7: note: candidate: std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::node_type&&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<int, int> >; std::set<_Key, _Compare, _Alloc>::node_type = std::_Node_handle<std::pair<int, int>, std::pair<int, int>, std::allocator<std::_Rb_tree_node<std::pair<int, int> > > >] insert(const_iterator __hint, node_type&& __nh) ^~~~~~ /usr/include/c++/7/bits/stl_set.h:593:7: note: candidate expects 2 arguments, 1 provided assistant.cpp:36:7: warning: unused variable 'A' [-Wunused-variable] int A = GetRequest(); ^ assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)': assistant.cpp:68:13: warning: unused variable 'k' [-Wunused-variable] int n = N, k = K, r = R, sz = (log2(n)); ^ assistant.cpp:68:20: warning: unused variable 'r' [-Wunused-variable] int n = N, k = K, r = R, sz = (log2(n)); ^