Submission #23781

#TimeUsernameProblemLanguageResultExecution timeMemory
23781HiasatLast supper (IOI12_supper)C++14
20 / 100
479 ms27120 KiB
#include <bits/stdc++.h> #include "advisor.h" using namespace std; void ComputeAdvice(int *C, int N, int K, int M) { int bits = M/N; bits = min(bits,17); for (int i = 0; i < N; ++i){ for(int k = bits-1; k >= 0 ; k--){ bool r = C[i]&(1<<k); WriteAdvice(r); } } }
#include <bits/stdc++.h> #include "assistant.h" using namespace std; typedef pair<int,int> pii; vector<int> nxt[100001]; int n , k , r; bool have[100001]; int go(int color,int cur){ vector<int>::iterator it = upper_bound(nxt[color].begin(),nxt[color].end(),cur); if(it == nxt[color].end()) return n; return *it; } void Assist(unsigned char *A, int N, int K, int R) { n = N; k = K; r = R; int bits = min(17,R/N); for (int i = 0; i < N; ++i) { int num = 0; for (int k = bits-1 ; k >= 0 ; k--) { num += A[i * bits + ((bits-1) - k)] * (1 << k); } nxt[num].push_back(i); } set< pii > q; for (int i = 0; i < K; ++i){ have[i] = 1; q.insert(make_pair(go(i,-1),i)); } for (int i = 0; i < N; i++) { int req = GetRequest(); if(have[req]){ q.erase(make_pair(go(req,i-1),req)); q.insert(make_pair(go(req,i),req)); continue; } pii src = (*(--q.end())); q.erase(src); PutBack(src.second); have[src.second] = 0; have[req] = 1; q.insert(make_pair(go(req,i),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...