# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
121404 |
2019-06-26T13:26:04 Z |
MAMBA |
Last supper (IOI12_supper) |
C++14 |
|
199 ms |
140104 KB |
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
void ComputeAdvice(int S[], int n, int k, int ignore) {
deque<int> c[n];
vector<bool> mark(n);
vector<bool> res(n + k);
priority_queue<pair<int, int>> pq;
rep(i, 0, k) {
c[i].push_back(i);
mark[i] = true;
}
rep(i, 0, n) c[S[i]].push_back(i + k);
rep(i, 0, k) {
int v = c[i].front();
c[i].pop_front();
int u = n + k;
if (!c[i].empty()) u = c[i].front();
pq.push({u, v});
}
rep(i, 0, n) {
c[S[i]].pop_front();
if (!mark[S[i]]) {
int id = pq.top().second;
pq.pop();
res[id] = true;
if (id >= k) id = S[id - k];
mark[id] = false;
mark[S[i]] = true;
}
int u = n + k;
if (!c[S[i]].empty()) u = c[S[i]].front();
pq.push({u, i + k});
}
rep(i, 0, k + n) WriteAdvice(res[i]);
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
void Assist(unsigned char A[], int n, int k, int ignore) {
vector<bool> mark(n);
vector<int> q;
int l = 0;
rep(i, 0, k) {
mark[i] = true;
if (A[i]) q.pb(i);
}
rep(i, 0, n) {
int g = GetRequest();
if (A[i + k]) q.pb(g);
if (!mark[g]) {
PutBack(q[l]);
mark[q[l++]] = false;
mark[g] = true;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
876 KB |
Output is correct |
2 |
Correct |
4 ms |
896 KB |
Output is correct |
3 |
Correct |
5 ms |
2048 KB |
Output is correct |
4 |
Correct |
7 ms |
5120 KB |
Output is correct |
5 |
Correct |
9 ms |
7424 KB |
Output is correct |
6 |
Correct |
10 ms |
7680 KB |
Output is correct |
7 |
Correct |
10 ms |
7936 KB |
Output is correct |
8 |
Correct |
11 ms |
7680 KB |
Output is correct |
9 |
Correct |
10 ms |
7680 KB |
Output is correct |
10 |
Correct |
10 ms |
7680 KB |
Output is correct |
11 |
Correct |
10 ms |
7680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
14592 KB |
Output is correct |
2 |
Correct |
96 ms |
70640 KB |
Output is correct |
3 |
Correct |
199 ms |
139704 KB |
Output is correct |
4 |
Correct |
194 ms |
139512 KB |
Output is correct |
5 |
Correct |
169 ms |
139368 KB |
Output is correct |
6 |
Correct |
181 ms |
139816 KB |
Output is correct |
7 |
Correct |
161 ms |
139736 KB |
Output is correct |
8 |
Correct |
143 ms |
118760 KB |
Output is correct |
9 |
Correct |
135 ms |
137000 KB |
Output is correct |
10 |
Correct |
162 ms |
139488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
111592 KB |
Output is correct |
2 |
Correct |
169 ms |
139568 KB |
Output is correct |
3 |
Correct |
163 ms |
139736 KB |
Output is correct |
4 |
Correct |
186 ms |
140104 KB |
Output is correct |
5 |
Correct |
178 ms |
138464 KB |
Output is correct |
6 |
Correct |
174 ms |
139728 KB |
Output is correct |
7 |
Correct |
184 ms |
139752 KB |
Output is correct |
8 |
Correct |
165 ms |
139472 KB |
Output is correct |
9 |
Correct |
176 ms |
139744 KB |
Output is correct |
10 |
Correct |
167 ms |
139616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
6144 KB |
Output is correct |
2 |
Correct |
22 ms |
7936 KB |
Output is correct |
3 |
Correct |
10 ms |
7424 KB |
Output is correct |
4 |
Correct |
10 ms |
7424 KB |
Output is correct |
5 |
Correct |
10 ms |
7680 KB |
Output is correct |
6 |
Correct |
10 ms |
7680 KB |
Output is correct |
7 |
Correct |
11 ms |
7680 KB |
Output is correct |
8 |
Correct |
12 ms |
7680 KB |
Output is correct |
9 |
Correct |
13 ms |
7680 KB |
Output is correct |
10 |
Correct |
10 ms |
7928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
180 ms |
138416 KB |
Output is correct - 120000 bits used |
2 |
Correct |
179 ms |
138472 KB |
Output is correct - 122000 bits used |
3 |
Correct |
184 ms |
138464 KB |
Output is correct - 125000 bits used |
4 |
Correct |
182 ms |
138464 KB |
Output is correct - 125000 bits used |
5 |
Correct |
199 ms |
138464 KB |
Output is correct - 125000 bits used |
6 |
Correct |
168 ms |
138464 KB |
Output is correct - 125000 bits used |
7 |
Correct |
173 ms |
138208 KB |
Output is correct - 124828 bits used |
8 |
Correct |
166 ms |
138512 KB |
Output is correct - 124910 bits used |
9 |
Correct |
179 ms |
138504 KB |
Output is correct - 125000 bits used |
10 |
Correct |
178 ms |
138504 KB |
Output is correct - 125000 bits used |