Submission #764761

#TimeUsernameProblemLanguageResultExecution timeMemory
764761boyliguanhanLast supper (IOI12_supper)C++17
100 / 100
82 ms6848 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; #define N 200100 int n, res[N], used[N], nxt[N], last[N]; void ComputeAdvice(int *C, int n, int k, int m) { priority_queue<pair<int,int>> q; for(int i = 0; i < n; i++) last[i] = n, used[i] = -1; for(int i = n; i--;) nxt[i] = last[C[i]], last[C[i]] = i; for(int i = 0; i < k; i++) q.push({last[i], used[i] = i}); for(int i = 0; i < n; i++){ if(used[C[i]]+1) { res[used[C[i]]] = 1; } else { used[q.top().second] = -1; q.pop(); } used[C[i]] = k+i; q.push({nxt[i], C[i]}); } for(int i = 0; i < n+k; i++) WriteAdvice(res[i]); }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; void Assist(unsigned char *A, int n, int k, int r) { set<int> y; priority_queue<int, vector<int>, greater<int>> q; for(int i=0;i<k;i++){ if(A[i]) y.insert(i); else q.push(i); } for(int i=k;i<n+k;i++){ int c = GetRequest(); if(y.find(c) != y.end()){ y.erase(c); } else { PutBack(q.top()); q.pop(); } if(A[i]) y.insert(c); else q.push(c); } }
#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...