Submission #1134685

#TimeUsernameProblemLanguageResultExecution timeMemory
1134685adaawfLast supper (IOI12_supper)C++20
100 / 100
90 ms5704 KiB
#include <bits/stdc++.h> #include "advisor.h" using namespace std; int f[200005], l[200005], g[200005], d[200005], dd[200005], c[200005]; void ComputeAdvice(int *C, int n, int k, int m) { int h = n + k; for (int i = h - 1; i >= k; i--) { c[i] = C[i - k]; } for (int i = 0; i < n; i++) { l[i] = 1e9; d[i] = dd[i] = 0; } for (int i = h - 1; i >= k; i--) { f[i] = l[c[i]]; l[c[i]] = i; } set<pair<int, int>> s; for (int i = 0; i < k; i++) { c[i] = i; s.insert({-l[i], i}); g[i] = i; dd[i] = 1; } for (int i = k; i < h; i++) { if (dd[c[i]] == 1) { s.erase({-i, g[c[i]]}); s.insert({-f[i], i}); } else { auto w = *s.begin(); d[w.second] = 1; s.erase(s.begin()); dd[c[w.second]] = 0; dd[c[i]] = 1; s.insert({-f[i], i}); } g[c[i]] = i; } for (int i = 0; i < h; i++) WriteAdvice(d[i]); }
#include <bits/stdc++.h> #include "assistant.h" using namespace std; int f[200005], l[200005], g[200005], d[200005], dd[200005]; void Assist(unsigned char *a, int n, int k, int r) { int h = n + k; for (int i = 0; i < n; i++) { dd[i] = 0; } stack<int> s; for (int i = 0; i < k; i++) { if (a[i]) s.push(i); dd[i] = 1; } for (int i = k; i < h; i++) { int x = GetRequest(); if (dd[x] == 0) { PutBack(s.top()); dd[s.top()] = 0; s.pop(); dd[x] = 1; } if (a[i]) s.push(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...