#include "advisor.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll a[101010];
void ComputeAdvice(int *C, int N, int K, int M)
{
ll i,j;
ll x=ceil(log(N)/log(2));
for(i=0;i<N;i++)
a[i]=C[i];
for(i=0;i<N;i++)
{
for(j=0;j<x;j++)
if(a[i]&(1<<j))
{
// cout<<"_1\n";
WriteAdvice(1);
}
else
{
// cout<<"_0\n";
WriteAdvice(0);
}
}
}
#include "assistant.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll z[1010101],isi[101010];
ll y[101010];
ll ada[101010];
ll las[101010];
void Assist(unsigned char *A, int N, int K, int R)
{
priority_queue<pair<ll,ll> > pq;
ll i,j;
ll x=ceil(log(N)/log(2));
for (i = 0; i < R; i++)
{
if(A[i])
{
// cout<<i<<"YA\n";
z[i]=1;
}
//cout<<i<<"___"<<A[i]<<"\n";
//z[(ll)A[i]]=1;
}
for (i = 0; i < N; i++)
for(j=0;j<x;j++)
isi[i]+=z[i*x+j]*(1<<j);
for(i=0;i<N;i++)
{
// cout<<i<<" "<<isi[i]<<"\n";
las[i]=N;
}
for(i=N-1;i>=0;i--)
{
y[i]=las[isi[i]];
las[isi[i]]=i;
}
for(i=0;i<K;i++)
pq.push(mp(las[i],i));
for(i=0;i<K;i++)
ada[i]=1;
for (i = 0; i < N; i++)
{
int req = GetRequest();
if(ada[req])
{
las[isi[i]]=y[i];
pq.push(mp(las[isi[i]],isi[i]));
}
else
{
while(!pq.empty()&&ada[pq.top().se]==0)pq.pop();
while(!pq.empty()&&las[pq.top().se]!=pq.top().fi)pq.pop();
ada[req]=1;
ll tem=pq.top().se;
// cout<<i<<" "<<tem<<"_) \n";
pq.pop();
ada[tem]=0;
las[isi[i]]=y[i];
pq.push(mp(las[isi[i]],isi[i]));
//pq.push(mp(las[req],req));
PutBack(tem);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
768 KB |
Output is correct |
2 |
Correct |
4 ms |
896 KB |
Output is correct |
3 |
Correct |
7 ms |
1044 KB |
Output is correct |
4 |
Correct |
12 ms |
1616 KB |
Output is correct |
5 |
Correct |
16 ms |
2036 KB |
Output is correct |
6 |
Correct |
17 ms |
2076 KB |
Output is correct |
7 |
Correct |
17 ms |
2204 KB |
Output is correct |
8 |
Correct |
18 ms |
1940 KB |
Output is correct |
9 |
Correct |
16 ms |
2032 KB |
Output is correct |
10 |
Correct |
16 ms |
2204 KB |
Output is correct |
11 |
Correct |
18 ms |
2068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
3536 KB |
Output is correct |
2 |
Correct |
162 ms |
15560 KB |
Output is correct |
3 |
Runtime error |
323 ms |
31820 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
265 ms |
28896 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
768 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
334 ms |
31828 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Runtime error |
328 ms |
31560 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Runtime error |
324 ms |
31820 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Runtime error |
322 ms |
31676 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
328 ms |
31612 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
328 ms |
31768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
326 ms |
31676 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
332 ms |
31944 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
335 ms |
31804 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
337 ms |
31792 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |