Submission #103274

#TimeUsernameProblemLanguageResultExecution timeMemory
103274wxh010910Last supper (IOI12_supper)C++17
100 / 100
161 ms17120 KiB
#include <bits/stdc++.h> #include "advisor.h" using namespace std; void ComputeAdvice(int* C, int N, int K, int M) { vector<int> pos(N, -1), nxt(N, N); priority_queue<pair<int, int>> q; for (int i = 0; i < N; ++i) { if (pos[C[i]] != -1) { nxt[pos[C[i]]] = i; } else if (C[i] < K) { q.emplace(i, C[i]); } pos[C[i]] = i; } vector<bool> in(N); for (int i = 0; i < K; ++i) { if (pos[i] == -1) { q.emplace(N, i); } in[i] = true; } vector<vector<int>> pass(N); for (int i = 0; i < N; ++i) { if (in[C[i]]) { pass[C[i]].push_back(0); } else { int take = q.top().second; q.pop(); in[C[i]] = true; in[take] = false; pass[take].push_back(1); } q.emplace(nxt[i], C[i]); } vector<int> ptr(N); for (int i = 0; i < N + K; ++i) { int color = i < K ? i : C[i - K]; if (ptr[color] == (int) pass[color].size()) { WriteAdvice(1); } else { WriteAdvice(pass[color][ptr[color]++]); } } }
#include <bits/stdc++.h> #include "assistant.h" using namespace std; void Assist(unsigned char* A, int N, int K, int R) { vector<bool> in(N); queue<int> q; for (int i = 0; i < K; ++i) { in[i] = true; if (A[i]) { q.push(i); } } for (int i = 0; i < N; ++i) { int c = GetRequest(); if (!in[c]) { in[c] = true; in[q.front()] = false; PutBack(q.front()); q.pop(); } if (A[i + K]) { q.push(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...