#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
#include "advisor.h"
//#include "assistant.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define vii vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define cnt(a)__builtin_popcount(a)
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
const int NN = 125005;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
int fir[NN];
vector<int> tmp[NN];
vector<int> used, last;
//int a[NN];
pii a[NN];
void ComputeAdvice(int *c, int n, int k, int m){
used.assign(n, -1);
for(int i=n-1;i>=0;i--){
a[i] = {used[c[i]], c[i]};
used[c[i]] = i;
tmp[i] = used;
}
memset(fir, -1, sizeof fir);
for(int i=0;i<n;i++){
if(fir[c[i]] == -1) fir[c[i]] = i;
}
set<pii> ss;
used.assign(n, 0);
last.assign(n, -1);
for(int i=0;i<k;i++) { last[i] = i, used[i] = 1; ss.insert({fir[i] == -1 ? mod : fir[i], i}); }
vector<int> ans(n+k);
for(int i=0;i<n;i++){
//for(auto x:ss) cout<<x.ss<<" ";
//cout<<"\n";
pii cur = a[i];
if(cur.ff == -1) cur.ff = mod;
if(used[cur.ss]){
int tt = cur.ff;
cur.ff = i;
auto x = ss.lb(cur);
if(x != ss.end()){
ss.erase(x);
ss.insert({tt, cur.ss});
}
last[cur.ss] = i+k;
ans[i+k] = 0;
continue;
}
auto er = --ss.end();
used[(*er).ss] = 0;
used[cur.ss] = 1;
//cout<<last[(*er).ss]<<" ";
ans[last[(*er).ss]] = 1;
last[cur.ss] = i+k;
ss.erase(er);
ss.insert(cur);
}
//cout<<"\n";
//for(int i=0;i<n;i++) cout<<ans[i]<<" ";
//cout<<"\n";
for(int i=0;i<n;i++) WriteAdvice(ans[i]);
}
/*
9 3 1500000
4 3 1 5 2 4 1 1 2
12 3 1000
0 2 1 2 2 3 0 1 2 3 0 2
4 2 12
2 0 3 0
7 2 14
1 1 2 3 1 3 2
*/
#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
//#include "advisor.h"
#include "assistant.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vll vector<ll>
#define vii vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define cnt(a)__builtin_popcount(a)
template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;}
template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;}
const int NN = 125005;
const int mod = 1e9+7;
const ll inf = 1e18;
const ld Pi = acos(-1);
int fir[NN];
vector<int> tmp[NN];
vector<int> used, last;
//int a[NN];
void Assist(unsigned char *a, int n, int k, int r) {
//int last = 0;
vector<int> A(n + k);
used.assign(n, 0);
set<int> ss;
for(int i=0;i<k;i++) ss.insert(i), used[i] =1;
for(int i=0;i<k;i++) A[i] = i;
for(int l = 0, r = 0; r < n-k; r++){
//for(auto x:ss) cout<<x<<" ";
//cout<<"\n";
//for(int i=0;i<r+k;i++) cout<<A[i]<<" ";
//cout<<"\n";
int cur = GetRequest();
A[r + k] = cur;
auto tt = ss.find(cur);
if(tt != ss.end()) continue;
while(l < r+k && !a[l]) l++;
//cout<<A[l]<<"\n";
PutBack(A[l]);
ss.erase(A[l]);
ss.insert(cur);
l++;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6984 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
140 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
145 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
45 ms |
70272 KB |
Error - GetRequest() must be called N times |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
156 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Runtime error |
158 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Runtime error |
148 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Runtime error |
169 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
150 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Runtime error |
149 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
149 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
153 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
151 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
152 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |