Submission #574909

#TimeUsernameProblemLanguageResultExecution timeMemory
574909FatihSolakLast supper (IOI12_supper)C++17
0 / 100
145 ms11392 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; void ComputeAdvice(int *c, int n, int k, int m){ vector<int> occ[n]; for(int i = n-1;i>=0;i--){ occ[c[i]].push_back(i); } for(int i = 0;i<k;i++){ WriteAdvice(occ[i].empty()); } for(int i = 0;i<n;i++){ occ[c[i]].pop_back(); WriteAdvice(occ[c[i]].empty()); } }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; struct BIT{ vector<int> bit; int n; BIT(int size){ n = size+5; bit.assign(n,0); } void upd(int pos,int val){ for(++pos;pos < n;pos += pos & -pos){ bit[pos] += val; } } int get(int pos){ int ret = 0; for(++pos;pos > 0;pos -= pos & -pos){ ret += bit[pos]; } return ret; } int get(int l,int r){ return get(r) - get(l-1); } int get_kth(int k){ int pos = 0; for(int i = 20;i>=0;i--){ if( pos + (1<<i) < n && bit[pos + (1<<i)] < k){ k -= bit[pos + (1<<i)]; pos += (1<<i); } } return pos; } }; void Assist(unsigned char *a, int n, int k, int r) { srand(time(NULL)); set<int> s,now; BIT bt(n); int last = 0; for(int i = 0;i<k;i++){ if(a[last++] == 1){ s.insert(i); } now.insert(i); bt.upd(i,1); } assert(k > 3); for (int i = 0; i < n; i++) { int req = GetRequest(); if(now.count(req) == 0){ int num = bt.get_kth(rand()%k + 1); if(s.size()){ num = *s.begin(); s.erase(s.begin()); } now.erase(num); bt.upd(num,-1); PutBack(num); now.insert(req); bt.upd(req,1); } if(a[last++] == 1){ s.insert(req); } } }
#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...