Submission #51909

#TimeUsernameProblemLanguageResultExecution timeMemory
51909rondojimLast supper (IOI12_supper)C++17
100 / 100
165 ms50560 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e5 + 5; vector<bool> used(MAXN, 0); int nxt[MAXN], pos[MAXN], top[MAXN]; struct col{ int color, next; bool operator<(const col &x) const { return next < x.next; } }; priority_queue<col> pq; vector<int> work[MAXN]; void ComputeAdvice(int *c, int n, int k, int m){ for(int i=0; i<n; ++i) pos[i] = -1, nxt[i] = n; for(int i=0; i<n; ++i){ if(pos[c[i]] == -1){ pos[c[i]] = i; if(c[i] < k) pq.push({c[i], i}); } else{ nxt[pos[c[i]]] = i; pos[c[i]] = i; } } for(int i=0; i<n; ++i){ if(pos[i] == -1){ if(i < k) pq.push({i, n}); } else nxt[pos[i]] = n; } for(int i=0; i<k; ++i) used[i] = true; for(int i=0; i<n; ++i){ if(used[c[i]]) work[c[i]].push_back(0); else{ col t = pq.top(); pq.pop(); used[t.color] = false; used[c[i]] = true; work[t.color].push_back(1); } pq.push({c[i], nxt[i]}); } for(int i=0; i<n+k; ++i){ int j = i < k ? i : c[i - k]; if(top[j] == work[j].size()) WriteAdvice(1); else WriteAdvice(work[j][top[j]++]); } }
#include "assistant.h" #include <vector> const int MAXN = 2e5 + 5; std::vector<bool> used(MAXN, false); int exclude[MAXN], top, bot; void Assist(unsigned char *advice, int n, int k, int r) { for(int i=0; i<k; ++i){ used[i] = true; if(advice[i]) exclude[top++] = i; } advice += k; for(int i=0; i<n; ++i){ int req = GetRequest(); if(!used[req]) { PutBack(exclude[bot]); used[req] = true; used[exclude[bot++]] = false; } if(advice[i]) exclude[top++] = req; } }

Compilation message (stderr)

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:54:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(top[j] == work[j].size()) WriteAdvice(1);
      ~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...