Submission #761620

#TimeUsernameProblemLanguageResultExecution timeMemory
761620SanguineChameleonLast supper (IOI12_supper)C++17
43 / 100
293 ms23248 KiB
#include "advisor.h" #include <bits/stdc++.h> using namespace std; const int maxN = 1e5 + 20; vector<int> pos[maxN]; void ComputeAdvice(int *C, int N, int K, int M) { int L = 1; while ((1 << L) < K) { L++; } for (int i = N - 1; i >= 0; i--) { pos[C[i]].push_back(i); } map<int, int> cur; set<pair<int, int>> S; for (int i = 0; i < K; i++) { S.emplace(pos[i].empty() ? N : pos[i].back(), i); cur[i] = i; } for (int i = 0; i < N; i++) { int x = -1; if (S.begin()->second == C[i]) { x = cur[C[i]]; cur[C[i]] = -1; S.erase(S.begin()); } else { x = cur[prev(S.end())->second]; cur[prev(S.end())->second] = -1; for (int j = 0; j < L; j++) { WriteAdvice((x >> j) & 1); } S.erase(prev(S.end())); } cur[C[i]] = x; pos[C[i]].pop_back(); S.emplace(pos[C[i]].empty() ? N : pos[C[i]].back(), C[i]); } }
#include "assistant.h" #include <bits/stdc++.h> using namespace std; const int maxK = 1e5 + 20; int colors[maxK]; void Assist(unsigned char *A, int N, int K, int R) { int L = 1; while ((1 << L) < K) { L++; } set<int> S; for (int i = 0; i < K; i++) { colors[i] = i; S.insert(i); } int pt = 0; for (int i = 0; i < N; i++) { int C = GetRequest(); if (S.find(C) != S.end()) { continue; } int pos = 0; for (int j = 0; j < L; j++) { pos |= (A[pt + j] << j); } pt += L; PutBack(colors[pos]); S.erase(colors[pos]); S.insert(C); colors[pos] = C; } }
#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...