Submission #97477

#TimeUsernameProblemLanguageResultExecution timeMemory
97477Alexa2001Last supper (IOI12_supper)C++17
100 / 100
117 ms10752 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; const int Nmax = 2e5 + 5; static int nxt[Nmax], last[Nmax], in[Nmax], c[Nmax], scoate[Nmax]; static priority_queue < pair<int,int> > heap; void ComputeAdvice(int *C, int N, int K, int M) { int i; for(i=0; i<N; ++i) last[i] = N+K; for(i=0; i<K; ++i) c[i] = i; for(; i<N+K; ++i) c[i] = C[i-K]; for(i=N+K-1; i>=0; --i) { nxt[i] = last[c[i]]; last[c[i]] = i; } for(i=0; i<K; ++i) { in[i] = 1; heap.push({ nxt[i], i }); } for(; i<N+K; ++i) { if(in[c[i]]) { heap.push({ nxt[i], i }); continue; } assert(heap.size()); int node = heap.top().second; heap.pop(); in[c[node]] = 0; in[c[i]] = 1; scoate[node] = 1; heap.push({ nxt[i], i }); } for(i=0; i<N+K; ++i) WriteAdvice(scoate[i]); }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; const int Nmax = 1e5 + 5; static int in[Nmax]; void Assist(unsigned char *A, int N, int K, int R) { int i; vector<int> active; for(i=0; i<K; ++i) { if(A[i]) active.push_back(i); in[i] = 1; } for(i=0; i<N; ++i) { int x = GetRequest(); if(in[x]) { if(A[K+i]) active.push_back(x); continue; } assert(active.size()); int y = active.back(); active.pop_back(); PutBack(y); in[y] = 0; in[x] = 1; if(A[K+i]) active.push_back(x); } assert(active.empty()); }
#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...