#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ALL(i) i.begin(), i.end()
#define SZ(i) int(i.size())
#define X first
#define Y second
#ifdef tmd
#define debug(...) fprintf(stderr,"#%d-(%s)=",__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y) {cerr<<x<<",";_do(y...);}
template<typename IT> ostream& __printRng (ostream& os, IT bg, IT ed) {
for (IT it=bg;it!=ed;it++) {
if (it == bg) os << "{" << *it;
else os << "," << *it;
}
return os << "}";
}
template<typename T> ostream& operator << (ostream& os, const vector<T> &vec) {
return __printRng(os, ALL(vec));
}
template<typename T, typename S> ostream& operator << (ostream& os, const pair<T,S> &pa) {
return os << "{" << pa.X << "," << pa.Y << "}";
}
#else
#define debug(...)
#endif
#include "advisor.h"
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i=0; i<N; i++) {
for (int j=0; j<13; j++) {
WriteAdvice((C[i]>>j)&1);
}
}
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define ALL(i) i.begin(), i.end()
#define SZ(i) int(i.size())
#define X first
#define Y second
#ifdef tmd
#define debug(...) fprintf(stderr,"#%d-(%s)=",__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y) {cerr<<x<<",";_do(y...);}
template<typename IT> ostream& __printRng (ostream& os, IT bg, IT ed) {
for (IT it=bg;it!=ed;it++) {
if (it == bg) os << "{" << *it;
else os << "," << *it;
}
return os << "}";
}
template<typename T> ostream& operator << (ostream& os, const vector<T> &vec) {
return __printRng(os, ALL(vec));
}
template<typename T, typename S> ostream& operator << (ostream& os, const pair<T,S> &pa) {
return os << "{" << pa.X << "," << pa.Y << "}";
}
#else
#define debug(...)
#endif
#include "assistant.h"
void Assist(unsigned char *a, int n, int k, int r) {
vector<int> c(n);
for (int i=0, ptr=0; i<n; i++) {
for (int j=0; j<13; j++) {
if (a[ptr++]) c[i] += (1<<j);
}
}
vector<int> nxt(n);
vector<int> lst(n, n);
for (int i=n-1; i>=0; i--) {
nxt[i] = lst[c[i]];
lst[c[i]] = i;
}
set<pii> pq;
set<int> st;
for (int i=0; i<k; i++) {
pq.emplace(pii(lst[i], i));
st.insert(i);
debug(lst[i], i);
}
for (int i=0; i<n; i++) {
int req = GetRequest();
assert(c[i] == req);
if (!st.count(req)) {
pii cur = *prev(pq.end());
pq.erase(prev(pq.end()));
debug(cur);
debug(nxt[i], req);
PutBack(cur.Y);
st.erase(cur.Y);
st.insert(req);
pq.emplace(nxt[i], req);
} else {
pq.erase({i, req});
pq.emplace(nxt[i], req);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
776 KB |
Output is correct |
2 |
Correct |
2 ms |
932 KB |
Output is correct |
3 |
Correct |
5 ms |
1144 KB |
Output is correct |
4 |
Correct |
12 ms |
1024 KB |
Output is correct |
5 |
Correct |
19 ms |
1336 KB |
Output is correct |
6 |
Correct |
19 ms |
1332 KB |
Output is correct |
7 |
Correct |
19 ms |
1204 KB |
Output is correct |
8 |
Correct |
19 ms |
1348 KB |
Output is correct |
9 |
Correct |
19 ms |
1468 KB |
Output is correct |
10 |
Correct |
22 ms |
1460 KB |
Output is correct |
11 |
Correct |
20 ms |
1332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
36 ms |
2536 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
273 ms |
16008 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
900 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
346 ms |
19160 KB |
Execution killed with signal 11 |
2 |
Runtime error |
341 ms |
19576 KB |
Execution killed with signal 11 |
3 |
Runtime error |
341 ms |
19928 KB |
Execution killed with signal 11 |
4 |
Runtime error |
336 ms |
19820 KB |
Execution killed with signal 11 |
5 |
Runtime error |
345 ms |
19816 KB |
Execution killed with signal 11 |
6 |
Runtime error |
354 ms |
19812 KB |
Execution killed with signal 11 |
7 |
Runtime error |
340 ms |
19956 KB |
Execution killed with signal 11 |
8 |
Runtime error |
340 ms |
20084 KB |
Execution killed with signal 11 |
9 |
Runtime error |
340 ms |
19792 KB |
Execution killed with signal 11 |
10 |
Runtime error |
339 ms |
19656 KB |
Execution killed with signal 11 |