#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
const int MAXN = 1e5 + 7;
int nxt[MAXN];
struct cmp{
bool operator()(int lvalue, int rvalue){
return nxt[lvalue] > nxt[rvalue];
}
};
set<int, cmp> pq;
int log_k, cnt[MAXN];
vector<int> v[MAXN];
int pos[MAXN];
vector<bool> ans;
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i = 0; i < N; ++i){
v[C[i]].push_back(i);
}
for(int i = 0; i < N; ++i){
v[i].push_back(N);
nxt[i] = v[i][0];
cnt[i] = 0;
}
for(int i = 0; i < N + K; ++i){
ans.push_back(false);
}
for(int i = 0; i < K; ++i){
pos[i] = i;
}
for(int i = 0; i < N; ++i){
if(pq.find(C[i]) == pq.end()){
int x = *pq.begin();
ans[pos[x]] = false;
pq.erase(x);
nxt[C[i]] = v[C[i]][++cnt[C[i]]];
pq.insert(C[i]);
pos[C[i]] = K + i;
}
else{
ans[pos[C[i]]] = true;
pq.erase(C[i]);
nxt[C[i]] = v[C[i]][++cnt[C[i]]];
pq.insert(C[i]);
pos[i] = K + i;
}
}
for(bool b: ans){
WriteAdvice(b);
}
}
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
const int MAXN = 1e5 + 7;
vector<int> v2;
bool b[MAXN], ok[MAXN];
void Assist(unsigned char *A, int N, int K, int R) {
return ;
for(int i = 0; i < K; ++i){
if(!A[i]){
ok[i] = true;
v2.push_back(i);
}
b[i] = true;
}
for(int i = 0; i < N; ++i){
int x = GetRequest();
if(b[x]){
ok[x] = A[i + K];
continue;
}
while(true){
if(b[v2.back()] && ok[v2.back()]){
b[v2.back()] = false;
ok[v2.back()] = false;
PutBack(v2.back());
ok[x] = A[i + K];
b[x] = true;
v2.push_back(x);
break;
}
v2.pop_back();
}
}
}
/*
4 2 100
2 0 3 2
*/
/*
g++ -DEVAL -Wall -static -std=c++11 -O2 -o supper grader.cpp assistant.cpp advisor.cpp
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
5360 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
6640 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
81 ms |
14704 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
5872 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
106 ms |
16824 KB |
Error - GetRequest() must be called N times |
2 |
Incorrect |
104 ms |
16632 KB |
Error - GetRequest() must be called N times |
3 |
Incorrect |
103 ms |
16880 KB |
Error - GetRequest() must be called N times |
4 |
Incorrect |
103 ms |
16824 KB |
Error - GetRequest() must be called N times |
5 |
Incorrect |
104 ms |
16824 KB |
Error - GetRequest() must be called N times |
6 |
Incorrect |
109 ms |
16880 KB |
Error - GetRequest() must be called N times |
7 |
Incorrect |
108 ms |
16768 KB |
Error - GetRequest() must be called N times |
8 |
Incorrect |
103 ms |
16880 KB |
Error - GetRequest() must be called N times |
9 |
Incorrect |
106 ms |
16880 KB |
Error - GetRequest() must be called N times |
10 |
Incorrect |
97 ms |
16624 KB |
Error - GetRequest() must be called N times |