#include "advisor.h"
#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
int vis[100001],predok[100001],is[100001],INF = 1e9+7;
void ComputeAdvice(int *c, int N, int K, int M) {
int i,n = log2(N)+1,j;
set <pii> q;
for (i=0;i<N;++i){
vis[i] = INF;
}
for (i=N-1;i>=0;--i){
predok[i] = vis[c[i]];
vis[c[i]] = i;
}
for (i=0;i<K;++i){
q.insert({-vis[i],i});
is[i]=1;
}
for (j=0;j<N;++j){
if (is[c[j]]){
int x = c[j];
for (i=0;i<n;++i)WriteAdvice(1);
q.erase({-vis[c[i]],x});
vis[c[j]] = predok[j];
}
else {
int x = q.begin()->sc;
q.erase(q.begin());
is[x] = 0;
for (i=0;i<n;++i){
if ((x&(1<<i)))WriteAdvice(1);
else WriteAdvice(0);
}
is[c[j]]=1;
}
q.insert({-predok[j],c[j]});
}
}
#include "assistant.h"
#include <bits/stdc++.h>
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
void Assist(unsigned char *A, int N, int K, int R) {
int i,n = log2(N)+1,j,ans;
for (i = 0; i < R; i +=n) {
ans = 0;
for (j = 0;j<n;++j){
int req = A[i+j];
if (req){
ans += (1<<j);
}
}
int req = GetRequest();
if (ans < N)PutBack(ans);
}
}
Compilation message
assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:40:13: warning: unused variable 'req' [-Wunused-variable]
40 | int req = GetRequest();
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
964 KB |
Output is correct |
2 |
Correct |
1 ms |
964 KB |
Output is correct |
3 |
Correct |
3 ms |
892 KB |
Output is correct |
4 |
Correct |
10 ms |
952 KB |
Output is correct |
5 |
Correct |
18 ms |
1340 KB |
Output is correct |
6 |
Correct |
18 ms |
1544 KB |
Output is correct |
7 |
Correct |
18 ms |
1556 KB |
Output is correct |
8 |
Correct |
20 ms |
1428 KB |
Output is correct |
9 |
Correct |
17 ms |
1568 KB |
Output is correct |
10 |
Correct |
19 ms |
1660 KB |
Output is correct |
11 |
Correct |
20 ms |
1556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
2112 KB |
Output is correct |
2 |
Correct |
208 ms |
9136 KB |
Output is correct |
3 |
Correct |
435 ms |
17808 KB |
Output is correct |
4 |
Correct |
410 ms |
14476 KB |
Output is correct |
5 |
Correct |
414 ms |
14948 KB |
Output is correct |
6 |
Correct |
421 ms |
15756 KB |
Output is correct |
7 |
Correct |
425 ms |
17532 KB |
Output is correct |
8 |
Correct |
370 ms |
14564 KB |
Output is correct |
9 |
Correct |
441 ms |
14308 KB |
Output is correct |
10 |
Correct |
436 ms |
18440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
346 ms |
14432 KB |
Output is correct |
2 |
Incorrect |
59 ms |
6884 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
1136 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
428 ms |
17292 KB |
Output is partially correct - 1700000 bits used |
2 |
Correct |
433 ms |
17948 KB |
Output is partially correct - 1700000 bits used |
3 |
Correct |
433 ms |
18104 KB |
Output is partially correct - 1700000 bits used |
4 |
Correct |
431 ms |
17804 KB |
Output is partially correct - 1700000 bits used |
5 |
Correct |
426 ms |
18040 KB |
Output is partially correct - 1700000 bits used |
6 |
Correct |
437 ms |
18044 KB |
Output is partially correct - 1700000 bits used |
7 |
Correct |
433 ms |
18200 KB |
Output is partially correct - 1697263 bits used |
8 |
Correct |
438 ms |
17832 KB |
Output is partially correct - 1700000 bits used |
9 |
Correct |
430 ms |
18048 KB |
Output is partially correct - 1700000 bits used |
10 |
Correct |
424 ms |
17160 KB |
Output is partially correct - 1700000 bits used |