Submission #283262

#TimeUsernameProblemLanguageResultExecution timeMemory
283262alexandra_udristoiuLast supper (IOI12_supper)C++14
0 / 100
106 ms10480 KiB
#include<algorithm> #include<set> #include "advisor.h" #define DIM 100005 #define f first #define s second using namespace std; static int viz[DIM], nxt[DIM], ff[2 * DIM], p[DIM]; static set< pair<int, int> > h; static set< pair<int, int> > :: iterator it; void ComputeAdvice(int *c, int n, int k, int m) { int i; for(i = 0; i < n; i++){ viz[i] = n; } for(i = n - 1; i >= 0; i--){ nxt[i] = viz[ c[i] ]; viz[ c[i] ] = i; } for(i = 0; i < k; i++){ p[i] = i; h.insert( make_pair(-viz[i], i) ); } for(i = 0; i < n; i++){ if(i < k){ viz[i] = 1; } else{ viz[i] = 0; } } for(i = 0; i < n; i++){ if(viz[ c[i] ] == 1){ h.erase( make_pair(-i, c[i]) ); p[ c[i] ] = i + k; h.insert( make_pair(-nxt[i], c[i]) ); continue; } it = h.begin(); viz[it->s] = 0; ff[ p[it->s] ] = 1; h.erase(it); p[ c[i] ] = i + k; h.insert( make_pair(-nxt[i], c[i]) ); } for(i = 0; i < n + k; i++){ WriteAdvice(ff[i]); } }
#include "assistant.h" #include<algorithm> #define DIM 100005 using namespace std; static int viz[DIM], w[2 * DIM]; void Assist(unsigned char *a, int n, int k, int r) { int i, x, nr = 0; for(i = 0; i < k; i++){ viz[i] = 1; if(a[i] == 1){ w[++nr] = i; } } for(i = 1; i <= n; i++){ x = GetRequest(); if(viz[x] == 0){ PutBack(w[nr]); viz[ w[nr] ] = 0; nr--; viz[x] = 1; } if(a[i + k - 1] == 1){ w[++nr] = 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...