Submission #32165

#TimeUsernameProblemLanguageResultExecution timeMemory
32165imeimi2000최후의 만찬 (IOI12_supper)C++14
100 / 100
116 ms17104 KiB
#include "advisor.h" #include <vector> #include <queue> using namespace std; typedef long long llong; static vector<bool> used(100000, false); static int nxt[100000]; static int pos[100000]; struct col { int color; int next; bool operator<(const col &x) const { return next < x.next; } }; static priority_queue<col> pq; static vector<int> work[100000]; static int top[100000]; 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> static std::vector<bool> used(100000, false); static int exclude[200000]; static int 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:61:14: 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...