Submission #820044

#TimeUsernameProblemLanguageResultExecution timeMemory
820044annabeth9680Last supper (IOI12_supper)C++17
100 / 100
110 ms13188 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1e5+20; vector<int> t[MAXN]; int A[2*MAXN]; void ComputeAdvice(int *C, int N, int K, int M){ //C = color requests; N = length of C; K = number of colors on the scaffold for(int i = N-1;i >= 0;--i){ t[C[i]].push_back(i); //the "times" color C[i] is needed, sorted in decreasing order } set<pair<int,int>> s; for(int i = 0;i<K;++i){ if(t[i].empty()) s.insert({N,i}); else s.insert({t[i].back(),i}); } for(int i = 0;i<N;++i){ if(s.begin()->first == i) s.erase(s.begin()); else{ A[prev(s.end())->second] = 1; s.erase(prev(s.end())); } t[C[i]].pop_back(); s.emplace(t[C[i]].empty() ? N : t[C[i]].back(),i+K); } for(int i = 0;i<K+N;++i) WriteAdvice(A[i]); }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; void Assist(unsigned char *A, int N, int K, int R) { vector<int> nxt; set<int> s; for (int i = 0; i < K; i++) { if(A[i] == 1) nxt.push_back(i); s.insert(i); } for(int i = 0; i < N; i++){ int x = GetRequest(); if(s.find(x) == s.end()){ int y = nxt.back(); PutBack(y); nxt.pop_back(); s.erase(y); s.insert(x); } if(A[i+K] == 1) nxt.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...