using namespace std;
#include <bits/stdc++.h>
#include "advisor.h"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<bool> vb;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
// void WriteAdvice(int x) {
// cout << x << " ";
// }
void ComputeAdvice(int *c, int n, int k, int m) {
set<int> scaffold;
rep(i,0,k) scaffold.insert(i);
vi advice(2*n, 0);
vi added(n, 0);
rep(i,0,k) added[i] = i;
rep(i,0,n) {
// for (auto k : scaffold) cout << k << " "; cout << endl;
int color = c[i];
if (scaffold.find(color) != scaffold.end()) {
added[color] = n+i;
continue;
}
set<int> passed;
bool adviced = false;
rep(j,i+1,n) {
if (passed.size() == scaffold.size() - 1) {
int res = 0;
for (auto x : scaffold) if (passed.find(x) == passed.end()) res = x;
advice[added[res]] = 1;
cout << "remove " << res << " at " << i << endl;
scaffold.erase(res);
adviced = true;
}
if (scaffold.find(c[j]) != scaffold.end()) passed.insert(c[j]);
}
if (!adviced) {
int res = 0;
for (auto x : scaffold) if (passed.find(x) == passed.end()) res = x;
advice[added[res]] = 1;
// cout << "remove " << res << " at " << i << endl;
scaffold.erase(res);
}
scaffold.insert(c[i]);
}
rep(i,0,2*n) WriteAdvice(advice[i]);
}
// int main() {
// int c[] ={0, 4, 5, 2, 1, 3};
// ComputeAdvice(c, 6, 3, -1);
// }
using namespace std;
#include <bits/stdc++.h>
#include "assistant.h"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<bool> vb;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
void Assist(unsigned char *a, int n, int k, int r) {
set<int> scaffold;
rep(i,0,k) scaffold.insert(i);
vector<int> advice(2*n);
rep(i,0,2*n) advice[i] = a[i];
queue<int> q;
rep(i,0,k) if (advice[i] == 1) q.push(i);
rep(i,0,n) {
int nextColor = GetRequest();
if (scaffold.find(nextColor) == scaffold.end()) {
assert(q.size() > 0);
int rem = q.front(); q.pop();
PutBack(rem);
scaffold.erase(rem);
scaffold.insert(nextColor);
}
if (advice[n + i] == 1) {
q.push(nextColor);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
520 KB |
Error - Invalid Access |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2575 ms |
864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2593 ms |
3028 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
546 ms |
1216 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2560 ms |
3392 KB |
Time limit exceeded |
2 |
Execution timed out |
2563 ms |
3540 KB |
Time limit exceeded |
3 |
Execution timed out |
2579 ms |
3784 KB |
Time limit exceeded |
4 |
Execution timed out |
2591 ms |
3784 KB |
Time limit exceeded |
5 |
Execution timed out |
2587 ms |
3796 KB |
Time limit exceeded |
6 |
Execution timed out |
2593 ms |
3796 KB |
Time limit exceeded |
7 |
Execution timed out |
2585 ms |
3784 KB |
Time limit exceeded |
8 |
Execution timed out |
2584 ms |
3776 KB |
Time limit exceeded |
9 |
Execution timed out |
2576 ms |
3784 KB |
Time limit exceeded |
10 |
Execution timed out |
2590 ms |
4188 KB |
Time limit exceeded |