Submission #576415

#TimeUsernameProblemLanguageResultExecution timeMemory
576415benson1029Last supper (IOI12_supper)C++14
0 / 100
152 ms77292 KiB
#include "advisor.h" #include<bits/stdc++.h> using namespace std; namespace advisor_var { deque<int> occ[100005]; bool inset[100005]; int id[100005]; int cnt[200005]; int timer = 0; multiset< pair<int,int> > st; }; void ComputeAdvice(int *C, int N, int K, int M) { using namespace advisor_var; for(int i=0; i<N; i++) { occ[C[i]].push_back(i); } for(int i=0; i<N; i++) occ[i].push_back(1e9); for(int i=0; i<K; i++) { inset[i] = true; st.insert({occ[i].front(), i}); id[i] = i; } timer = K; for(int i=0; i<N; i++) { if(inset[C[i]]) { ++cnt[id[C[i]]]; st.erase({occ[C[i]].front(), C[i]}); occ[C[i]].pop_front(); st.insert({occ[C[i]].front(), C[i]}); } else { int curr = (*prev(st.end())).second; st.erase(prev(st.end())); inset[curr] = false; inset[C[i]] = true; occ[C[i]].pop_front(); st.insert({occ[C[i]].front(), C[i]}); id[C[i]] = timer; ++timer; } } for(int i=0; i<timer; i++) { WriteAdvice(0); for(int j=0; j<cnt[i]; j++) WriteAdvice(1); } }
#include "assistant.h" #include<bits/stdc++.h> using namespace std; namespace assistant_var { int cnt[100005]; int v[100005]; int id[100005]; bool inset[100005]; queue<int> canthrow; }; void Assist(unsigned char *A, int N, int K, int R) { using namespace assistant_var; int ptr = -1; for(int i = 0; i < K+N; i++) { ptr++; while(ptr+1 < R && A[ptr+1]==1) { cnt[i]++; ptr++; } } for(int i = 0; i < K; i++) { v[i] = i; inset[i] = true; id[i] = i; if(cnt[i]==0) canthrow.push(i); } for(int i = 0; i < N; i++) { v[K+i] = GetRequest(); if(inset[v[K+i]]) { cnt[id[v[K+i]]]--; if(cnt[id[v[K+i]]]==0) canthrow.push(v[K+i]); } else { PutBack(canthrow.front()); inset[canthrow.front()] = false; inset[v[K+i]] = true; id[v[K+i]] = K+i; canthrow.pop(); if(cnt[K+i]==0) canthrow.push(v[K+i]); } } }
#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...