Submission #860472

#TimeUsernameProblemLanguageResultExecution timeMemory
860472nguyentunglamLast supper (IOI12_supper)C++17
100 / 100
68 ms10820 KiB
#include "advisor.h" #include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; vector<int> nxt[N]; bool chosen[N], rest[N]; void ComputeAdvice(int *C, int N, int K, int M) { for(int i = N - 1; i >= 0; i--) nxt[C[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++) { int x = C[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; chosen[x] = 1; int tmp = nxt[x].empty() ? N : nxt[x].back(); Q.push({tmp, x}); rest[i] = 0; } else { Q.push({nxt[x].empty() ? N : nxt[x].back(), x}); rest[i] = 1; } } for(int i = N - 1; i >= 0; i--) nxt[C[i]].push_back(i); for(int i = 0; i < K; i++) { int tmp = nxt[i].empty() ? N : nxt[i].back(); WriteAdvice(rest[tmp]); } for(int i = 0; i < N; i++) { int x = C[i]; nxt[x].pop_back(); int tmp = nxt[x].empty() ? N : nxt[x].back(); WriteAdvice(rest[tmp]); } }
#include "assistant.h" #include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; bool in[N]; void Assist(unsigned char *A, int N, int K, int R) { int cnt = 0; vector<int> useless; for(int i = 0; i < K; i++) { if (!int(A[cnt])) useless.push_back(i); cnt++; in[i] = 1; } for(int i = 0; i < N; i++) { int x = GetRequest(); if (!in[x]) { assert(useless.size()); int dog = useless.back(); useless.pop_back(); PutBack(dog); in[dog] = 0; } in[x] = 1; if (!int(A[cnt])) useless.push_back(x); cnt++; } }
#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...