#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
static queue<int> q[100010];
static set<pii> s;
static bool ans[200010];
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0; i<N; i++) {
q[C[i]].em(i);
}
for(int i=0; i<N; i++)
q[i].em(N);
for(int i=0; i<K; i++) {
s.insert(mp(q[i].front(), i - K));
}
for(int i=0; i<N; i++) {
if(s.begin()->fi == i) {
s.erase(s.begin());
q[C[i]].pop();
s.insert(mp(q[C[i]].front(), i));
}
else {
int x = prev(s.end())->se;
ans[x + K] = true;
s.erase(prev(s.end()));
q[C[i]].pop();
s.insert(mp(q[C[i]].front(), i));
}
}
for(int i=0; i<N+K; i++) {
WriteAdvice(ans[i]);
}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define em emplace
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;
static int n;
static set<int> t;
static vector<int> v[100010], s;
static int c[200010];
void Assist(unsigned char *A, int N, int K, int R) {
n = N;
for(int i=0; i<K; i++) {
if(A[i]) s.eb(i);
c[i] = i;
v[i].eb(i);
}
for(int i = K; i < N + K; i++) {
int x = GetRequest();
c[i] = x;
if(A[i]) s.eb(i);
if(v[x].size() && !A[v[x].back()]) {
v[x].eb(i);
continue;
}
int y = s.back();
s.pop_back();
PutBack(c[y]);
v[x].eb(i);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
54 ms |
135152 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
65 ms |
135664 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
162 ms |
139504 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
60 ms |
135408 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
192 ms |
140016 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
195 ms |
140272 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
193 ms |
140528 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
193 ms |
140528 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
193 ms |
140616 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
201 ms |
140664 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
194 ms |
140632 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
188 ms |
140528 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
199 ms |
140528 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Incorrect |
184 ms |
140528 KB |
Error - Putting back a color that is not on the scaffold |