Submission #65099

#TimeUsernameProblemLanguageResultExecution timeMemory
65099aquablitz11Last supper (IOI12_supper)C++14
100 / 100
390 ms41832 KiB
#include <bits/stdc++.h> #include "advisor.h" using namespace std; using pii = pair<int, int>; static const int N = 200010; static const int INF = 1e9; static int ptr[N], last[N], ans[N]; static vector<int> seqpos[N]; static set<pii> S; static int getnext(int x) { if (ptr[x] < (int)seqpos[x].size()) return seqpos[x][ptr[x]]; else return INF; } static void movenext(int x) { S.erase(pii(getnext(x), x)); ++ptr[x]; S.insert(pii(getnext(x), x)); } void ComputeAdvice(int *C, int n, int k, int m) { for (int i = 0; i < n; ++i) seqpos[C[i]].push_back(i); for (int i = 0; i < k; ++i) S.insert(pii(getnext(i), i)), last[i] = i; for (int i = 0; i < n; ++i) { int x = C[i]; if (S.count(pii(getnext(x), x))) { //printf("found %d\n", x); } else { auto it = prev(S.end()); ans[last[it->second]] = 1; //printf("threw away %d\n", it->second); S.erase(it); S.insert(pii(getnext(x), x)); } movenext(x); last[x] = k+i; } for (int i = 0; i < n+k; ++i) WriteAdvice(ans[i]); }
#include <bits/stdc++.h> #include "assistant.h" using namespace std; void Assist(unsigned char *A, int n, int k, int r) { r = 0; set<int> has; deque<int> avail; for (int i = 0; i < k; ++i) { has.insert(i); if (A[r++] == 1) avail.push_back(i); } for (int i = 0; i < n; ++i) { int x = GetRequest(); if (!has.count(x)) { has.erase(avail.front()); PutBack(avail.front()); avail.pop_front(); has.insert(x); } if (A[r++] == 1) avail.push_back(x); } }
#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...