#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
typedef long long ll;
struct dat{
int l, r, x;
dat(){}
dat(int l, int r, int x): l(l), r(r), x(x){}
bool operator<(const dat &nxt)const{
return r<nxt.r;
}
};
int n, k, m;
int arr[100002];
vector<int> occurence[100002];
set<dat> st;
set<int> now;
vector<bool> bits;
void ComputeAdvice(int *C, int N, int K, int M){
n = N, k = K, m = M;
bits.resize(n+k);
for(int i=0; i<n; i++){
arr[i] = C[i];
occurence[arr[i]].push_back(i);
}
for(int i=0; i<n; i++){
occurence[i].push_back(1e9);
reverse(occurence[i].begin(), occurence[i].end());
}
for(int i=0; i<k; i++){
now.insert(i);
st.insert(dat(i, occurence[i].back(), i));
}
for(int i=0; i<n; i++){
occurence[arr[i]].pop_back();
if(now.find(arr[i]) != now.end()) continue;
dat tmp = *st.rbegin();
st.erase(prev(st.end()));
now.erase(tmp.x);
bits[tmp.l] = true;
st.insert(dat(k+i, occurence[arr[i]].back(), arr[i]));
now.insert(arr[i]);
}
for(int i=0; i<n+k; i++){
WriteAdvice(bits[i]);
}
return;
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
typedef long long ll;
namespace {
int n, k, r;
bool arr[200002];
vector<int> order;
set<int> st;
stack<int> stk;
}
void Assist(unsigned char *A, int N, int K, int R){
n = N, k = K, r = R;
assert(r = n+k);
for(int i=0; i<r; i++) arr[i] = A[i];
for(int i=0; i<k; i++){
order.push_back(i);
st.insert(i);
if(arr[i]) stk.push(i);
}
for(int i=k; i<n+k; i++){
int tmp = GetRequest();
order.push_back(tmp);
if(st.find(tmp) == st.end()){
int tmp2 = stk.top();
PutBack(tmp2);
stk.pop();
}
if(arr[i]) stk.push(tmp);
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
3048 KB |
Output is correct |
2 |
Incorrect |
2 ms |
3048 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
4076 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
129 ms |
12048 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
3624 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
149 ms |
13428 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Incorrect |
153 ms |
13816 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
153 ms |
14396 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
154 ms |
14156 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
153 ms |
14652 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
152 ms |
14204 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
154 ms |
14204 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
156 ms |
14332 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
154 ms |
14436 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
152 ms |
15352 KB |
Output isn't correct - not an optimal way |