Submission #1024429

#TimeUsernameProblemLanguageResultExecution timeMemory
1024429socpiteLast supper (IOI12_supper)C++17
100 / 100
65 ms8284 KiB
#include "advisor.h" #include<bits/stdc++.h> using namespace std; void ComputeAdvice(int *C, int N, int K, int M) { vector<int> ans(N+K, 0), prv(N, N), next(N), active(N, 0); set<pair<int, int>> st; for(int i = N-1; i >= 0; i--){ next[i] = prv[C[i]]; // cout << C[i] << " " << next[i] << endl; prv[C[i]] = i; } for(int i = 0; i < K; i++){ active[i] = 1; st.insert({prv[i], i}); prv[i] = i; } for(int i = 0; i < N; i++){ if(active[C[i]]){ ans[prv[C[i]]] = 1; st.erase(make_pair(i, C[i])); st.insert({next[i], C[i]}); } else{ auto tmp = *st.rbegin(); active[tmp.second] = 0; active[C[i]] = 1; st.erase(tmp); st.insert({next[i], C[i]}); } prv[C[i]] = i+K; } for(auto v: ans)WriteAdvice(v); }
#include "assistant.h" #include<bits/stdc++.h> using namespace std; void Assist(unsigned char *A, int N, int K, int R) { vector<int> bad; vector<int> active(N, 0); vector<int> prv(N, -1); for(int i = 0; i < K; i++){ active[i] = 1; if(!A[i])bad.push_back(i); prv[i] = i; } for(int i = 0; i < N; i++){ int x = GetRequest(); if(!active[x]){ if(prv[x] != -1)assert(!A[prv[x]]); active[bad.back()] = 0; active[x] = 1; PutBack(bad.back()); bad.pop_back(); } if(!A[i+K])bad.push_back(x); prv[x] = i+K; } }
#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...