#include <bits/stdc++.h>
using namespace std;
#include "advisor.h"
#define pb push_back
void ComputeAdvice(int *C, int N, int K, int M)
{
int L=__builtin_clz(0)-__builtin_clz(N-1);
function<void(int)> WriteInt=[&](int x)
{
for(int i=0;i<L;i++) WriteAdvice(x&1),x>>=1;
};
for(int i=0;i<N;i++) WriteInt(C[i]);
}
#include <bits/stdc++.h>
using namespace std;
#include "assistant.h"
#define pb push_back
void Assist(unsigned char *A, int N, int K, int R)
{
int L=__builtin_clz(0)-__builtin_clz(N-1);
int cur=0;
function<int()> ReadInt=[&]()
{
int ans=0;
for(int i=0;i<L;i++)
{
if(A[cur++]) ans+=1<<i;
}
return ans;
};
vector<int> reqs;
for(int i=0;i<N;i++) reqs.pb(ReadInt());
vector<queue<int>> pos;
pos.resize(N);
for(int i=0;i<N;i++) pos[reqs[i]].push(i);
for(int i=0;i<N;i++) pos[i].push(N);
vector<bool> in(N,0);
set<pair<int,int>> st;
function<void(int,int)> push=[&](int x, int tm)
{
while(pos[x].front()<=tm) pos[x].pop();
int t=pos[x].front();
st.insert({t,x});
in[x]=1;
};
for(int i=0;i<K;i++) push(i,-1);
for(int i=0;i<N;i++)
{
int req=GetRequest();
if(in[req])
{
st.erase({pos[req].front(),req});
push(req,i);
}
else
{
int down=st.rbegin()->second;
st.erase(--st.end());
in[down]=0;
push(req,i);
PutBack(down);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
776 KB |
Output is correct |
2 |
Correct |
4 ms |
768 KB |
Output is correct |
3 |
Correct |
7 ms |
1564 KB |
Output is correct |
4 |
Correct |
12 ms |
3128 KB |
Output is correct |
5 |
Correct |
20 ms |
4640 KB |
Output is correct |
6 |
Correct |
19 ms |
4628 KB |
Output is correct |
7 |
Correct |
20 ms |
4636 KB |
Output is correct |
8 |
Correct |
20 ms |
4508 KB |
Output is correct |
9 |
Correct |
19 ms |
4636 KB |
Output is correct |
10 |
Correct |
20 ms |
4664 KB |
Output is correct |
11 |
Correct |
22 ms |
4636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
8668 KB |
Output is correct |
2 |
Correct |
224 ms |
41368 KB |
Output is correct |
3 |
Correct |
501 ms |
83400 KB |
Output is correct |
4 |
Correct |
457 ms |
81648 KB |
Output is correct |
5 |
Correct |
456 ms |
81844 KB |
Output is correct |
6 |
Correct |
461 ms |
82104 KB |
Output is correct |
7 |
Correct |
476 ms |
82628 KB |
Output is correct |
8 |
Correct |
450 ms |
70552 KB |
Output is correct |
9 |
Correct |
409 ms |
80276 KB |
Output is correct |
10 |
Correct |
501 ms |
83156 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
387 ms |
66664 KB |
Output is correct |
2 |
Incorrect |
20 ms |
5632 KB |
Error - advice is too long |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
776 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
476 ms |
82752 KB |
Output is partially correct - 1700000 bits used |
2 |
Partially correct |
492 ms |
82832 KB |
Output is partially correct - 1700000 bits used |
3 |
Partially correct |
472 ms |
83004 KB |
Output is partially correct - 1700000 bits used |
4 |
Partially correct |
473 ms |
82900 KB |
Output is partially correct - 1700000 bits used |
5 |
Partially correct |
481 ms |
82796 KB |
Output is partially correct - 1700000 bits used |
6 |
Partially correct |
481 ms |
82780 KB |
Output is partially correct - 1700000 bits used |
7 |
Partially correct |
475 ms |
82764 KB |
Output is partially correct - 1697263 bits used |
8 |
Partially correct |
501 ms |
82784 KB |
Output is partially correct - 1700000 bits used |
9 |
Partially correct |
481 ms |
82712 KB |
Output is partially correct - 1700000 bits used |
10 |
Partially correct |
482 ms |
82784 KB |
Output is partially correct - 1700000 bits used |