Submission #993206

#TimeUsernameProblemLanguageResultExecution timeMemory
99320612345678Last supper (IOI12_supper)C++17
100 / 100
118 ms21200 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; const int nxx=1e5+5; int bits; vector<int> d[nxx], idx(nxx), rem[nxx], order[nxx]; set<pair<int, int>> mx; void ComputeAdvice(int *C, int N, int K, int M) { for (int i=N-1; i>=0; i--) d[C[i]].push_back(i); for (int i=0; i<K; i++) { idx[i]=i; if (d[i].empty()) mx.insert({1e9, i}); else mx.insert({d[i].back(), i}); } for (int i=0; i<N; i++) { if (mx.find({i, C[i]})!=mx.end()) { d[C[i]].pop_back(); mx.erase({i, C[i]}); } else { auto col=prev(mx.end())->second; rem[col].push_back(i); mx.erase(prev(mx.end())); d[C[i]].pop_back(); } if (d[C[i]].empty()) mx.insert({1e9, C[i]}); else mx.insert({d[C[i]].back(), C[i]}); } for (int i=0; i<N; i++) d[i].clear(), rem[i].push_back(1e8), reverse(rem[i].begin(), rem[i].end()); for (int i=N-1; i>=0; i--) d[C[i]].push_back(i); for (int i=0; i<K; i++) { if (d[i].empty()||d[i].back()>rem[i].back()) WriteAdvice(1); else WriteAdvice(0); } for (int i=0; i<N; i++) { d[C[i]].pop_back(); while (rem[C[i]].back()<i) rem[C[i]].pop_back(); if (d[C[i]].empty()||d[C[i]].back()>rem[C[i]].back()) WriteAdvice(1); else WriteAdvice(0); } }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; const int nx=1e5+5; set<int> s; queue<int> q; void Assist(unsigned char *A, int N, int K, int R) { for (int i=0; i<K; i++) if (A[i]) q.push(i); for (int i=0; i<K; i++) s.insert(i); for (int i=0; i<N; i++) { int t=GetRequest(); if (s.find(t)==s.end()) { s.erase(q.front()); PutBack(q.front()); q.pop(); s.insert(t); } if (A[i+K]) q.push(t); } return; }
#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...