#include <bits/stdc++.h>
#include "advisor.h"
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
int n;
vi G[100005];
priority_queue<pii> activasion;
set<int> in_pq;
vi advice, out;
void ComputeAdvice(int *C, int N, int K, int M) {
n = N;
for(int i = n-1; i >= 0; i--)
G[C[i]].pb(i);
for(int i = 0; i < K; i++){
int when = n - 1;
if(!G[i].empty()) when = G[i].back();
activasion.push(mp(when, i));
in_pq.insert(i);
}
for(int i = 0; i < n + K; i++) advice.pb(1);
for(int i = 0; i < K; i++) out.pb(i);
for(int i = 0; i < n; i++){
G[C[i]].pop_back();
out[C[i]] = K + i;
if(in_pq.find(C[i]) == in_pq.end()){
pii sega = activasion.top();
activasion.pop();
in_pq.erase(sega.second);
advice[out[sega.second]] = 0;
}
int when = 0;
in_pq.insert(C[i]);
if(G[C[i]].empty())when = -n-1;
else when = G[C[i]].back();
activasion.push(mp(when, C[i]));
}
for(int i = 0; i < n+K; i++)
WriteAdvice(advice[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
void Assist(unsigned char *A, int N, int K, int R) {
int n = N, k = K;
set<int> odma, in;
for(int i = 0; i < K; i++){
if(A[i] == 0) odma.insert(i);
in.insert(i);
}
for(int i = 0; i < n; i++){
int adv = GetRequest();
if(odma.find(adv) == odma.end()){
PutBack(*odma.begin());
in.erase(*odma.begin());
odma.erase(odma.begin());
}
in.insert(adv);
if(A[i+k] == 0) odma.insert(adv);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2948 KB |
Error - Putting back a color when it is already on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
6100 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
19 ms |
12388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
5588 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
21 ms |
13648 KB |
Execution killed with signal 11 |
2 |
Runtime error |
21 ms |
13820 KB |
Execution killed with signal 11 |
3 |
Runtime error |
21 ms |
14292 KB |
Execution killed with signal 11 |
4 |
Runtime error |
22 ms |
14220 KB |
Execution killed with signal 11 |
5 |
Runtime error |
28 ms |
14288 KB |
Execution killed with signal 11 |
6 |
Runtime error |
28 ms |
14248 KB |
Execution killed with signal 11 |
7 |
Runtime error |
23 ms |
14232 KB |
Execution killed with signal 11 |
8 |
Runtime error |
22 ms |
14292 KB |
Execution killed with signal 11 |
9 |
Runtime error |
21 ms |
14152 KB |
Execution killed with signal 11 |
10 |
Runtime error |
23 ms |
16396 KB |
Execution killed with signal 11 |