# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
813025 | Andrey | Last supper (IOI12_supper) | C++14 | 2604 ms | 10396 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include "advisor.h"
using namespace std;
vector<int> haha[100001];
void ComputeAdvice(int *c, int n, int k, int m) {
int br = 0,z = 1;
while(z <= n) {
z*=2;
br++;
}
vector<int> ans(0);
vector<int> p(n);
vector<bool> bruh(n);
int a,b;
priority_queue<pair<int,int>> idk;
for(int i = 0; i < n; i++) {
haha[c[i]].push_back(i);
}
for(int i = 0; i < n; i++) {
haha[i].push_back(INT_MAX);
}
for(int i = 0; i < k; i++) {
bruh[i] = true;
idk.push({haha[i][0],i});
}
for(int i = 0; i < n; i++) {
if(bruh[c[i]]) {
p[c[i]]++;
idk.push({haha[c[i]][p[c[i]]],c[i]});
ans.push_back(INT_MAX);
}
else {
a = idk.top().first;
b = idk.top().second;
bruh[b] = false;
idk.pop();
ans.push_back(b);
p[c[i]]++;
idk.push({haha[c[i]][p[c[i]]],c[i]});
bruh[c[i]] = true;
}
}
vector<int> sb(n);
for(int i = 0; i < n; i++) {
if(ans[i] != INT_MAX) {
sb[ans[i]]++;
}
}
for(int i = 0; i < n; i++) {
for(int j = 0; j < sb[i]; j++) {
WriteAdvice(1);
}
WriteAdvice(0);
}
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *a, int n, int k, int r) {
int br = 0,z = 1,x = 0,b,p,sm;;
vector<int> sb(n);
for(int i = 0; i < r; i++) {
if((int)a[i] == 0) {
br++;
}
else {
sb[br]++;
}
}
vector<bool> bruh(n);
for(int i = 0; i < k; i++) {
bruh[i] = true;
}
for(int i = 0; i < n; i++) {
b = GetRequest();
if(!bruh[b]) {
p = -1;
sm = INT_MAX;
for(int j = 0; j < n; j++) {
if(bruh[j] && sb[j] < sm && sb[j] > 0) {
sm = sb[j];
p = j;
}
}
bruh[b] = true;
bruh[p] = false;
sb[p]--;
PutBack(p);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |