#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));
}
for(int i=0; i<K; i++){
s.insert(pi(getnxt(i, -1), i));
is_in[i] = 1;
}
sort(nexts.begin(), nexts.end());
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++){
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) {
for(int i=0; i<R; i+=17){
int bits = 0;
for(int j=0; j<17; 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:10:7: warning: unused variable 'req' [-Wunused-variable]
int req = GetRequest();
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
856 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1036 KB |
Output isn't correct - not an optimal way |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
43 ms |
2616 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
360 ms |
15424 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
15424 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
489 ms |
18528 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
504 ms |
18752 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
473 ms |
19048 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
551 ms |
19112 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
442 ms |
19112 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
435 ms |
19112 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
491 ms |
19112 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
491 ms |
19112 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
498 ms |
19112 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
474 ms |
19112 KB |
Output isn't correct - not an optimal way |