#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();
st.erase(tmp);
st.insert(tmp2);
}
if(arr[i]) stk.push(tmp);
}
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3240 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3044 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
4056 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
125 ms |
11104 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
3588 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
160 ms |
12340 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Incorrect |
159 ms |
12756 KB |
Error - Putting back a color when it is already on the scaffold |
3 |
Incorrect |
164 ms |
13320 KB |
Error - Putting back a color when it is already on the scaffold |
4 |
Incorrect |
155 ms |
13164 KB |
Error - Putting back a color when it is already on the scaffold |
5 |
Incorrect |
161 ms |
13324 KB |
Error - Putting back a color when it is already on the scaffold |
6 |
Incorrect |
161 ms |
13120 KB |
Error - Putting back a color when it is already on the scaffold |
7 |
Incorrect |
160 ms |
12988 KB |
Error - Putting back a color when it is already on the scaffold |
8 |
Incorrect |
168 ms |
13244 KB |
Error - Putting back a color when it is already on the scaffold |
9 |
Incorrect |
158 ms |
13184 KB |
Error - Putting back a color when it is already on the scaffold |
10 |
Incorrect |
211 ms |
17332 KB |
Error - Not putting back color when it is not on the scaffold |