Submission #860457

#TimeUsernameProblemLanguageResultExecution timeMemory
860457nguyentunglamLast supper (IOI12_supper)C++17
20 / 100
295 ms20948 KiB
#include "advisor.h" #include<bits/stdc++.h> using namespace std; void ComputeAdvice(int *C, int N, int K, int M) { int T = log2(N) + 1; for(int i = 0; i < N; i++) { for(int j = 0; j < T; j++) WriteAdvice(C[i] >> j & 1); } }
#include "assistant.h" #include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int query[N]; bool chosen[N]; vector<int> nxt[N]; void Assist(unsigned char *A, int N, int K, int R) { int T = log2(N) + 1; int cnt = 0; for(int i = 0; i < N; i++) { for(int j = 0; j < T; j++) { if (int(A[cnt])) query[i] |= (1 << j); cnt++; } } for(int i = N - 1; i >= 0; i--) nxt[query[i]].push_back(i); priority_queue<pair<int, int> > Q; for(int i = 0; i < K; i++) { int tmp = nxt[i].empty() ? N : nxt[i].back(); Q.push({tmp, i}); chosen[i] = 1; } for(int i = 0; i < N; i++) { GetRequest(); int x = query[i]; nxt[x].pop_back(); while (!Q.empty() && chosen[Q.top().second] == 0) Q.pop(); if (chosen[x] == 0) { int useless, j; tie(useless, j) = Q.top(); Q.pop(); chosen[j] = 0; PutBack(j); chosen[x] = 1; int tmp = nxt[x].empty() ? N : nxt[x].back(); Q.push({tmp, x}); } else { Q.push({nxt[x].empty() ? N : nxt[x].back(), x}); } } }
#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...