#include "advisor.h"
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef pair<int,int> pi;
set<pi> s;
vector<pi> nexts;
int query[100005];
int is_in[100005];
int getnxt(int val, int time){
auto t = upper_bound(nexts.begin(), nexts.end(), pi(val, time));
if(t->first != val) return 1e9;
return t->second;
}
void ComputeAdvice(int *C, int N, int K, int M) {
for(int i=0; i<N; i++){
nexts.push_back(pi(C[i], i));
}
sort(nexts.begin(), nexts.end());
for(int i=0; i<K; i++){
s.insert(pi(getnxt(i, -1), i));
is_in[i] = 1;
}
for(int i=0; i<N; i++){
query[i] = N;
if(is_in[C[i]]){
if(s.find(pi(i, C[i])) != s.end()) s.erase(pi(i, C[i]));
s.insert(pi(getnxt(C[i], i), C[i]));
}
else{
auto t = --s.end();
query[i] = t->second;
is_in[t->second] = 0;
s.erase(t);
s.insert(pi(getnxt(C[i], i), C[i]));
is_in[C[i]] = 1;
}
}
for(int i=0; i<N; i++){
if(N <= 5000){
for(int j=0; j<13; j++){
WriteAdvice((query[i] >> j) & 1);
}
}
else{
for(int j=0; j<17; j++){
WriteAdvice((query[i] >> j) & 1);
}
}
}
}
#include "assistant.h"
void Assist(unsigned char *A, int N, int K, int R) {
int p = (N <= 5000 ? 13 : 17);
for(int i=0; i<R; i+=p){
int bits = 0;
for(int j=0; j<p; j++){
bits |= (A[i + j] << j);
}
int req = GetRequest();
if(bits == N){
continue;
}
else{
PutBack(bits);
}
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:11:7: warning: unused variable 'req' [-Wunused-variable]
int req = GetRequest();
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
648 KB |
Output is correct |
2 |
Correct |
4 ms |
720 KB |
Output is correct |
3 |
Correct |
7 ms |
1080 KB |
Output is correct |
4 |
Correct |
13 ms |
1184 KB |
Output is correct |
5 |
Correct |
19 ms |
1728 KB |
Output is correct |
6 |
Correct |
26 ms |
1728 KB |
Output is correct |
7 |
Correct |
20 ms |
1728 KB |
Output is correct |
8 |
Correct |
19 ms |
1864 KB |
Output is correct |
9 |
Correct |
25 ms |
1864 KB |
Output is correct |
10 |
Correct |
23 ms |
2016 KB |
Output is correct |
11 |
Correct |
30 ms |
2016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
2904 KB |
Output is correct |
2 |
Correct |
257 ms |
9232 KB |
Output is correct |
3 |
Correct |
516 ms |
19696 KB |
Output is correct |
4 |
Correct |
439 ms |
19696 KB |
Output is correct |
5 |
Correct |
444 ms |
19696 KB |
Output is correct |
6 |
Correct |
445 ms |
19696 KB |
Output is correct |
7 |
Correct |
456 ms |
19696 KB |
Output is correct |
8 |
Correct |
388 ms |
19696 KB |
Output is correct |
9 |
Correct |
417 ms |
19696 KB |
Output is correct |
10 |
Correct |
526 ms |
19696 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
404 ms |
19696 KB |
Output is correct |
2 |
Incorrect |
115 ms |
19696 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
19696 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
516 ms |
19696 KB |
Output is partially correct - 1700000 bits used |
2 |
Partially correct |
474 ms |
19696 KB |
Output is partially correct - 1700000 bits used |
3 |
Partially correct |
463 ms |
19696 KB |
Output is partially correct - 1700000 bits used |
4 |
Partially correct |
483 ms |
19696 KB |
Output is partially correct - 1700000 bits used |
5 |
Partially correct |
474 ms |
19696 KB |
Output is partially correct - 1700000 bits used |
6 |
Partially correct |
535 ms |
19696 KB |
Output is partially correct - 1700000 bits used |
7 |
Partially correct |
472 ms |
19696 KB |
Output is partially correct - 1697263 bits used |
8 |
Partially correct |
485 ms |
19696 KB |
Output is partially correct - 1700000 bits used |
9 |
Partially correct |
538 ms |
19696 KB |
Output is partially correct - 1700000 bits used |
10 |
Partially correct |
456 ms |
19696 KB |
Output is partially correct - 1700000 bits used |