# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
361577 |
2021-01-30T15:39:08 Z |
MetB |
Last supper (IOI12_supper) |
C++14 |
|
201 ms |
11960 KB |
#include <iostream>
#include <vector>
#include <set>
#include "advisor.h"
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M) {
vector<vector<int>> last(N);
vector<int> ans(N), ans_k(K);
vector<int> request(N, -1);
vector<int> ptr(N, 0), st(N);
set<pair<int, int>> s;
for (int i = 0; i < N; i++) {
last[C[i]].push_back(i);
}
for (int i = 0; i < N; i++) {
last[i].push_back(N);
}
for (int i = 0; i < K; i++) {
s.insert({last[i][0], i});
st[i] = 1;
}
for (int i = 0; i < N; i++) {
/*for (auto a : s) {
cout << a.first << ' ' << a.second << endl;
}
cout << "----\n";*/
request[C[i]] = i;
if (!st[C[i]]) {
int x = s.rbegin()->second;
s.erase(s.find(*s.rbegin()));
st[x] = 0;
if (request[x] != -1) ans[request[x]] = 1;
else ans_k[x] = 1;
while(last[C[i]][ptr[C[i]]] <= i) ptr[C[i]]++;
s.insert({last[C[i]][ptr[C[i]]], C[i]});
} else {
s.erase({last[C[i]][ptr[C[i]]], C[i]});
while(last[C[i]][ptr[C[i]]] <= i) ptr[C[i]]++;
s.insert({last[C[i]][ptr[C[i]]], C[i]});
}
st[C[i]] = 1;
}
for (int i = 0; i < K; i++) {
WriteAdvice(ans_k[i]);
}
for (int i = 0; i < N; i++) {
WriteAdvice(ans[i]);
}
}
#include <iostream>
#include <vector>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int N, int K, int R) {
vector<int> st(N);
vector<int> bottom_shelf;
for (int i = 0; i < K; i++) {
if (A[i]) bottom_shelf.push_back(i);
st[i] = 1;
}
A += K;
for (int i = 0; i < N; i++) {
int x = GetRequest();
if (!st[x]) {
PutBack(bottom_shelf.back());
bottom_shelf.pop_back();
}
st[x] = 1;
if (A[i]) bottom_shelf.push_back(x);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
980 KB |
Output is correct |
2 |
Correct |
1 ms |
740 KB |
Output is correct |
3 |
Correct |
3 ms |
876 KB |
Output is correct |
4 |
Incorrect |
3 ms |
1016 KB |
Error - Not putting back color when it is not on the scaffold |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
1964 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
9364 KB |
Output is correct |
2 |
Correct |
149 ms |
11504 KB |
Output is correct |
3 |
Correct |
148 ms |
11552 KB |
Output is correct |
4 |
Correct |
147 ms |
11684 KB |
Output is correct |
5 |
Incorrect |
159 ms |
11404 KB |
Error - Not putting back color when it is not on the scaffold |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1392 KB |
Output is correct |
2 |
Incorrect |
6 ms |
1308 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
165 ms |
11188 KB |
Error - Not putting back color when it is not on the scaffold |
2 |
Correct |
141 ms |
11320 KB |
Output is correct - 122000 bits used |
3 |
Correct |
176 ms |
11600 KB |
Output is correct - 125000 bits used |
4 |
Correct |
139 ms |
11452 KB |
Output is correct - 125000 bits used |
5 |
Correct |
156 ms |
11380 KB |
Output is correct - 125000 bits used |
6 |
Correct |
144 ms |
11704 KB |
Output is correct - 125000 bits used |
7 |
Correct |
142 ms |
11452 KB |
Output is correct - 124828 bits used |
8 |
Correct |
201 ms |
11960 KB |
Output is correct - 124910 bits used |
9 |
Correct |
155 ms |
11580 KB |
Output is correct - 125000 bits used |
10 |
Incorrect |
147 ms |
11452 KB |
Error - Not putting back color when it is not on the scaffold |