Submission #1078105

#TimeUsernameProblemLanguageResultExecution timeMemory
1078105PbezzLast supper (IOI12_supper)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; void ComputeAdvice(int *C, int n, int k, int m) { int inf = 2*n; set<int> cur; set<pair<int, int>> pri; vector<set<int>> nxt(n); for(int i = 0; i < n; ++i){ nxt[C[i]].insert(i); } for(int i = 0; i < n; ++i){ nxt[i].insert(inf); } for(int i = 0; i < k; ++i){ cur.insert(i); pri.insert({-*nxt[i].begin(),i}); } vector<int> rem(n); for(int i = 0; i < n; ++i){ /*for(auto[x, y] : pri) printf("%i %i", x, y); printf("\n");*/ int c = C[i]; if(cur.find(c) != cur.end()){ rem[i] = -1; pri.erase({-*nxt[c].begin(),c}); nxt[c].erase(nxt[c].begin()); pri.insert({-*nxt[c].begin(),c}); }else{ auto[x, cr] = *pri.begin(); rem[i] = cr; pri.erase(pri.begin()); cur.erase(cr); nxt[c].erase(nxt[c].begin()); pri.insert({-*nxt[c].begin(),c}); cur.insert(c); } } /*for(int r : rem) printf("%i ", r); printf("\n");*/ vector<int> lst(n, -1); vector<unsigned char> sol(n+k, 0); for(int i = 0; i < k; ++i){ lst[i] = i; } for(int i = 0; i < n; ++i){ int c = C[i]; int r = rem[i]; if(r == -1){ sol[lst[c]] = 1; }else{ sol[lst[r]] = 0; } lst[c] = i+k; } for(unsigned char bit : sol){ WriteAdvice(bit); } /*for(unsigned char c : sol) printf("%i", c); printf("\n");*/ }
#include <bits/stdc++.h> using namespace std; void Assist(unsigned char *A, int n, int k, int r) { int i; set<pair<unsigned char, int>> shelf; for(i = 0; i < k; i++){ shelf.insert({A[i], i}); } for (i = 0; i < n; i++) { int c = GetRequest(); if(shelf.find({1, c}) != shelf.end()){ shelf.erase({1, c}); shelf.insert({A[i+k], c}); continue; } PutBack(shelf.begin()->second); shelf.erase(shelf.begin()); shelf.insert({A[i+k], c}); } }

Compilation message (stderr)

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:59:5: error: 'WriteAdvice' was not declared in this scope; did you mean 'ComputeAdvice'?
   59 |     WriteAdvice(bit);
      |     ^~~~~~~~~~~
      |     ComputeAdvice

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:12:13: error: 'GetRequest' was not declared in this scope
   12 |     int c = GetRequest();
      |             ^~~~~~~~~~
assistant.cpp:18:5: error: 'PutBack' was not declared in this scope
   18 |     PutBack(shelf.begin()->second);
      |     ^~~~~~~