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;
// for (auto k : scaffold) cout << k << " "; cout << endl;
rep(i,0,n) {
int color = c[i];
added[color] = n+i;
if (scaffold.find(color) != scaffold.end()) {
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 << ", advice: " << added[res] << 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 << ", advice: " << added[res] << endl;
scaffold.erase(res);
}
scaffold.insert(c[i]);
// for (auto k : scaffold) cout << k << " "; cout << endl;
}
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()) {
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 |
Correct |
2 ms |
516 KB |
Output is correct |
2 |
Correct |
1 ms |
516 KB |
Output is correct |
3 |
Correct |
2 ms |
724 KB |
Output is correct |
4 |
Correct |
50 ms |
748 KB |
Output is correct |
5 |
Correct |
16 ms |
912 KB |
Output is correct |
6 |
Correct |
376 ms |
856 KB |
Output is correct |
7 |
Correct |
155 ms |
856 KB |
Output is correct |
8 |
Correct |
660 ms |
892 KB |
Output is correct |
9 |
Correct |
857 ms |
924 KB |
Output is correct |
10 |
Correct |
894 ms |
988 KB |
Output is correct |
11 |
Correct |
904 ms |
1048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2576 ms |
852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2581 ms |
3024 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
571 ms |
876 KB |
Output is correct |
2 |
Correct |
744 ms |
960 KB |
Output is correct |
3 |
Correct |
186 ms |
752 KB |
Output is correct |
4 |
Correct |
122 ms |
812 KB |
Output is correct |
5 |
Correct |
289 ms |
788 KB |
Output is correct |
6 |
Correct |
404 ms |
820 KB |
Output is correct |
7 |
Correct |
707 ms |
916 KB |
Output is correct |
8 |
Correct |
847 ms |
976 KB |
Output is correct |
9 |
Correct |
876 ms |
1104 KB |
Output is correct |
10 |
Correct |
553 ms |
1316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2566 ms |
3400 KB |
Time limit exceeded |
2 |
Execution timed out |
2566 ms |
3548 KB |
Time limit exceeded |
3 |
Execution timed out |
2587 ms |
3784 KB |
Time limit exceeded |
4 |
Execution timed out |
2592 ms |
3784 KB |
Time limit exceeded |
5 |
Execution timed out |
2590 ms |
3796 KB |
Time limit exceeded |
6 |
Execution timed out |
2570 ms |
3796 KB |
Time limit exceeded |
7 |
Execution timed out |
2567 ms |
3784 KB |
Time limit exceeded |
8 |
Execution timed out |
2568 ms |
3780 KB |
Time limit exceeded |
9 |
Execution timed out |
2566 ms |
3780 KB |
Time limit exceeded |
10 |
Execution timed out |
2579 ms |
4184 KB |
Time limit exceeded |