//In the name of God
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll a[maxn], ok[maxn], ptr[maxn], prio[maxn], ind[maxn], ls[maxn], msg[maxn];
vector<ll> vec[maxn];
set<pll> st;
void ComputeAdvice(int *c, int n, int k, int m){
for(ll i = 0; i < k; i++){
a[i] = i;
ls[i] = i;
ind[i] = i;
ok[i] = 1;
}
for(ll i = 0; i < n; i++){
vec[c[i]].pb(i);
}
for(ll i = 0; i < n; i++){
vec[i].pb(n);
vec[i].pb(n);
}
for(ll i = 0; i < n; i++){
prio[i] = vec[i][ptr[i]++];
if(i < k) st.insert(Mp(-prio[i], i));
}
for(ll i = 0; i < n; i++){
if(ok[c[i]]){
st.erase(Mp(-prio[c[i]], c[i]));
prio[c[i]] = vec[c[i]][ptr[c[i]]++];
st.insert(Mp(-prio[c[i]], c[i]));
ls[c[i]] = i + k;
continue;
}
ll j = st.begin()->S;
msg[ls[j]] = 1;
st.erase(st.begin());
ok[j] = 0;
ok[c[i]] = 1;
ind[c[i]] = ind[j];
prio[c[i]] = vec[c[i]][ptr[c[i]]++];
st.insert(Mp(-prio[c[i]], c[i]));
ls[c[i]] = i + k;
}
for(ll i = 0; i < n + k; i++){
WriteAdvice(msg[i]);
}
}
/*int main(){
int c[100], n, k, m;
cin >> n >> k >> m;
for(ll i = 0; i < n; i++){
cin >> c[i];
}
ComputeAdvice(c, n, k, m);
}*/
//In the name of God
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
ll _ok[maxn];
void Assist(unsigned char *A, int n, int k, int r) {
vector<ll> vec;
for(ll i = 0; i < k; i++){
if(A[i]) vec.pb(i);
_ok[i] = 1;
}
for(ll i = 0; i < n; i++){
ll x = GetRequest();
if(_ok[x]) continue;
ll y = vec.back();
vec.pop_back();
if(A[i + k]) vec.pb(x);
PutBack(y);
_ok[y] = 0;
_ok[x] = 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5260 KB |
Output is correct |
2 |
Incorrect |
3 ms |
5256 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
6832 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
155 ms |
18276 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
6076 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
165 ms |
21056 KB |
Error - Putting back a color that is not on the scaffold |
2 |
Incorrect |
164 ms |
21400 KB |
Error - Putting back a color that is not on the scaffold |
3 |
Incorrect |
175 ms |
21592 KB |
Error - Putting back a color that is not on the scaffold |
4 |
Incorrect |
167 ms |
21536 KB |
Error - Putting back a color that is not on the scaffold |
5 |
Incorrect |
174 ms |
21664 KB |
Error - Putting back a color that is not on the scaffold |
6 |
Incorrect |
173 ms |
21560 KB |
Error - Putting back a color that is not on the scaffold |
7 |
Incorrect |
170 ms |
21556 KB |
Error - Putting back a color that is not on the scaffold |
8 |
Incorrect |
168 ms |
21908 KB |
Error - Putting back a color that is not on the scaffold |
9 |
Incorrect |
168 ms |
21588 KB |
Error - Putting back a color that is not on the scaffold |
10 |
Runtime error |
164 ms |
23636 KB |
Execution killed with signal 6 |