#include<bits/stdc++.h>
#include "advisor.h"
using namespace std;
vector<int> haha[100001];
void ComputeAdvice(int *c, int n, int k, int m) {
int br = 0,z = 1;
while(z <= n) {
z*=2;
br++;
}
vector<int> ans(0);
vector<int> p(n);
vector<bool> bruh(n);
int a,b;
priority_queue<pair<int,int>> idk;
for(int i = 0; i < n; i++) {
haha[c[i]].push_back(i);
}
for(int i = 0; i < n; i++) {
haha[i].push_back(INT_MAX);
}
for(int i = 0; i < k; i++) {
bruh[i] = true;
idk.push({haha[i][0],i});
}
for(int i = 0; i < n; i++) {
if(bruh[c[i]]) {
p[c[i]]++;
if(haha[c[i]][p[c[i]]] == INT_MAX) {
idk.push({INT_MAX,c[i]});
}
else {
idk.push({haha[c[i]][p[c[i]]],c[i]});
}
ans.push_back(INT_MAX);
}
else {
do {
a = idk.top().first;
b = idk.top().second;
idk.pop();
}while(!bruh[b]);
bruh[b] = false;
idk.pop();
ans.push_back(b);
p[c[i]]++;
if(haha[c[i]][p[c[i]]] == INT_MAX) {
idk.push({INT_MAX,c[i]});
}
else {
idk.push({rand()%n,c[i]});
}
bruh[c[i]] = true;
}
}
for(int i = 0; i < n; i++) {
for(int j = br-1; j >= 0; j--) {
if((1 << j)&ans[i]) {
WriteAdvice(1);
}
else {
WriteAdvice(0);
}
}
}
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *a, int n, int k, int r) {
int br = 0,z = 1,x = 0;
while(z <= n) {
z*=2;
br++;
}
int y = 0;
for(int i = 0; i < n; i++) {
GetRequest();
x = 0;
for(int j = 0; j < br; j++) {
x*=2;
x+=(int)a[y];
y++;
}
if(x < n) {
PutBack(x);
}
}
}
Compilation message
advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:15:9: warning: variable 'a' set but not used [-Wunused-but-set-variable]
15 | int a,b;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2960 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2956 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2554 ms |
3028 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2571 ms |
6608 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
3056 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2544 ms |
7148 KB |
Time limit exceeded |
2 |
Execution timed out |
2562 ms |
7120 KB |
Time limit exceeded |
3 |
Incorrect |
318 ms |
18372 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
292 ms |
18356 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
291 ms |
18312 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
299 ms |
18348 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
302 ms |
18488 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
297 ms |
18436 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
289 ms |
18404 KB |
Output isn't correct - not an optimal way |
10 |
Execution timed out |
2577 ms |
7084 KB |
Time limit exceeded |