#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#ifndef LOCAL
#define cerr if(false) cerr
#endif
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < n; i ++)
#define revn(i, n) for(int i = n - 1; i >= 0; i --)
typedef long long ll;
template<class T, template<class T2, class A=allocator<T2> > class cont> inline ostream &operator <<(ostream &out, const cont<T> &x) { for(const auto &it : x) { out << it << " ";} return out;}
template<class T, template<class T2, class A=allocator<T2> > class cont> inline istream &operator >>(istream &in, cont<T> &x) { for(auto &it : x) { in >> it;} return in;}
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
const int MAX_N = 1e5 + 10;
ll nxt[MAX_N];
ll change[MAX_N];
bool ans[MAX_N];
int n, k, m;
int current[MAX_N];
void ComputeAdvice(int *arr, int n, int k, int m) {
for(int i = 0; i < n; i ++) {
nxt[i] = n;
}
for(int i = n - 1; i >= 0; i --) {
change[i] = nxt[arr[i]];
nxt[arr[i]] = i;
}
set<pair<int, int> > st;
for(int i = 0; i < k; i ++) {
st.insert({nxt[i], i});
current[i] = i;
}
int cnt = k;
auto removeMax = [&st]() {
auto it = st.end();
it --;
ans[current[(*it).second]] = 1;
st.erase(it);
};
for(int i = 0; i < n; i ++) {
if(st.find({i, arr[i]}) != st.end()) {
auto it = st.find({i, arr[i]});
ans[current[(*it).second]] = 0;
st.erase(it);
} else {
removeMax();
}
nxt[arr[i]] = change[i];
current[arr[i]] = cnt ++;
st.insert({nxt[arr[i]], arr[i]});
}
for(int i = 0; i < cnt; i ++) {
WriteAdvice(ans[i]);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#ifndef LOCAL
#define cerr if(false) cerr
#endif
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < n; i ++)
#define revn(i, n) for(int i = n - 1; i >= 0; i --)
typedef long long ll;
template<class T, template<class T2, class A=allocator<T2> > class cont> inline ostream &operator <<(ostream &out, const cont<T> &x) { for(const auto &it : x) { out << it << " ";} return out;}
template<class T, template<class T2, class A=allocator<T2> > class cont> inline istream &operator >>(istream &in, cont<T> &x) { for(auto &it : x) { in >> it;} return in;}
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
void Assist(unsigned char *ans, int n, int k, int r) {
set<int> st;
set<int> bad;
for(int i = 0; i < k; i ++) {
st.insert(i);
if(ans[i]) {
bad.insert(i);
}
}
int cnt = k;
for(int i = 0; i < n; i ++) {
int now = GetRequest();
if(st.find(now) != st.end()) {
st.erase(st.find(now));
} else {
auto something = bad.begin();
PutBack(*something);
st.erase(*something);
bad.erase(*something);
}
st.insert(now);
if(ans[cnt]) {
bad.insert(now);
}
cnt ++;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
500 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
764 KB |
Output is correct |
4 |
Correct |
3 ms |
648 KB |
Output is correct |
5 |
Correct |
3 ms |
800 KB |
Output is correct |
6 |
Correct |
4 ms |
912 KB |
Output is correct |
7 |
Correct |
6 ms |
940 KB |
Output is correct |
8 |
Correct |
5 ms |
928 KB |
Output is correct |
9 |
Correct |
5 ms |
880 KB |
Output is correct |
10 |
Correct |
6 ms |
1060 KB |
Output is correct |
11 |
Correct |
6 ms |
928 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
1396 KB |
Output is correct |
2 |
Correct |
50 ms |
3960 KB |
Output is correct |
3 |
Incorrect |
37 ms |
5800 KB |
Error - advice must be 0 or 1 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
98 ms |
7424 KB |
Output is correct |
2 |
Incorrect |
39 ms |
5312 KB |
Error - advice must be 0 or 1 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
884 KB |
Output is correct |
2 |
Correct |
6 ms |
932 KB |
Output is correct |
3 |
Correct |
5 ms |
812 KB |
Output is correct |
4 |
Correct |
4 ms |
812 KB |
Output is correct |
5 |
Correct |
4 ms |
800 KB |
Output is correct |
6 |
Correct |
5 ms |
928 KB |
Output is correct |
7 |
Correct |
6 ms |
940 KB |
Output is correct |
8 |
Correct |
6 ms |
928 KB |
Output is correct |
9 |
Correct |
6 ms |
928 KB |
Output is correct |
10 |
Correct |
8 ms |
1188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
5188 KB |
Error - advice must be 0 or 1 |
2 |
Incorrect |
37 ms |
5288 KB |
Error - advice must be 0 or 1 |
3 |
Incorrect |
39 ms |
5440 KB |
Error - advice must be 0 or 1 |
4 |
Incorrect |
40 ms |
5360 KB |
Error - advice must be 0 or 1 |
5 |
Incorrect |
40 ms |
5340 KB |
Error - advice must be 0 or 1 |
6 |
Incorrect |
39 ms |
5412 KB |
Error - advice must be 0 or 1 |
7 |
Incorrect |
41 ms |
5456 KB |
Error - advice must be 0 or 1 |
8 |
Incorrect |
40 ms |
5360 KB |
Error - advice must be 0 or 1 |
9 |
Incorrect |
40 ms |
5344 KB |
Error - advice must be 0 or 1 |
10 |
Incorrect |
30 ms |
5492 KB |
Error - advice must be 0 or 1 |