Submission #122177

#TimeUsernameProblemLanguageResultExecution timeMemory
122177Osama_AlkhodairyLast supper (IOI12_supper)C++17
0 / 100
2595 ms7220 KiB
#include <bits/stdc++.h> #include "advisor.h" //~ #include "grader.cpp" using namespace std; void ComputeAdvice(int *C, int N, int K, int M) { vector <int> las(N, N); vector <int> nex(N); for(int i = N - 1 ; i >= 0 ; i--){ nex[i] = las[C[i]]; las[C[i]] = i; } set <pair <int, int> > ready; for(int i = 0 ; i < K ; i++){ ready.insert(make_pair(las[i], i)); } vector <int> p(N); for(int i = 0 ; i < N ; i++){ if(ready.count(make_pair(i, C[i]))){ ready.erase(ready.find(make_pair(i, C[i]))); ready.insert(make_pair(nex[i], C[i])); continue; } ready.erase(--ready.end()); ready.insert(make_pair(nex[i], C[i])); p[i] = 1; } for(int i = 0 ; i < K ; i++){ if(las[i] == N) WriteAdvice(1); else WriteAdvice(p[las[i]]); } for(int i = 0 ; i < N ; i++){ if(nex[i] == N) WriteAdvice(1); else WriteAdvice(p[nex[i]]); } }
#include <bits/stdc++.h> #include "assistant.h" using namespace std; void Assist(unsigned char *A, int N, int K, int R) { set <int> ready, passive; for(int i = 0 ; i < K ; i++){ if(A[i] == 1) passive.insert(i); ready.insert(i); } for(int i = 0 ; i < N ; i++){ int x = GetRequest(); if(ready.count(x) == 0){ int put = -1; for(auto &j : passive){ if(ready.count(j)){ put = j; break; } } assert(put != -1); PutBack(put); ready.erase(put); ready.insert(x); } if(A[K + i] == 1) passive.insert(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...