#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
int arr[200005],nex[200005],l[200005],advice[200005];
pair<int,int> cur[100005];
void ComputeAdvice(int *c,int n,int k,int m)
{
for (int i=0;i<k;i++)
arr[i]=i;
for (int i=k;i<n+k;i++)
arr[i]=c[i-k];
for (int i=n+k-1;i>=0;i--)
{
if (!l[arr[i]])
nex[i]=1e9;
else
nex[i]=l[arr[i]];
l[arr[i]]=i;
}
set<pair<int,int>,greater<pair<int,int> > > s;
for (int i=0;i<n;i++)
{
cur[i]={-1,-1};
if (i<k)
{
s.insert({nex[i],i});
cur[i]={nex[i],i};
}
}
for (int i=k;i<n+k;i++)
{
if (cur[arr[i]].first==-1)
{
cur[arr[s.begin()->second]]={-1,-1};
s.erase(s.begin());
}
else
{
s.erase(cur[arr[i]]);
advice[cur[arr[i]].second]=1;
s.insert(cur[arr[i]]);
}
cur[arr[i]]={nex[i],i};
s.insert({nex[i],i});
}
for (int i=0;i<n+k;i++)
WriteAdvice(advice[i]);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
bool in[100005];
void Assist(unsigned char *advice,int n,int k,int r)
{
set<int> s;
for (int i=0;i<k;i++)
{
in[i]=1;
if (!advice[i])
s.insert(i);
}
for (int i=k;i<n+k;i++)
{
int cur=GetRequest();
if (!in[cur])
{
PutBack(*s.begin());
in[*s.begin()]=0;
s.erase(s.begin());
in[cur]=1;
}
if (!advice[i])
s.insert(cur);
else if (s.find(cur)!=s.end())
s.erase(cur);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
880 KB |
Output is correct |
2 |
Correct |
4 ms |
956 KB |
Output is correct |
3 |
Correct |
5 ms |
1040 KB |
Output is correct |
4 |
Correct |
7 ms |
1052 KB |
Output is correct |
5 |
Correct |
7 ms |
1116 KB |
Output is correct |
6 |
Correct |
8 ms |
1292 KB |
Output is correct |
7 |
Correct |
10 ms |
1520 KB |
Output is correct |
8 |
Correct |
9 ms |
1264 KB |
Output is correct |
9 |
Correct |
9 ms |
1264 KB |
Output is correct |
10 |
Correct |
11 ms |
1520 KB |
Output is correct |
11 |
Correct |
10 ms |
1672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
2032 KB |
Output is correct |
2 |
Correct |
63 ms |
8176 KB |
Output is correct |
3 |
Correct |
142 ms |
16624 KB |
Output is correct |
4 |
Correct |
77 ms |
9200 KB |
Output is correct |
5 |
Correct |
82 ms |
9968 KB |
Output is correct |
6 |
Correct |
105 ms |
12528 KB |
Output is correct |
7 |
Correct |
136 ms |
15856 KB |
Output is correct |
8 |
Correct |
109 ms |
12320 KB |
Output is correct |
9 |
Correct |
79 ms |
9608 KB |
Output is correct |
10 |
Correct |
162 ms |
17904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
122 ms |
13024 KB |
Output is correct |
2 |
Correct |
148 ms |
16944 KB |
Output is correct |
3 |
Correct |
146 ms |
17032 KB |
Output is correct |
4 |
Correct |
153 ms |
17648 KB |
Output is correct |
5 |
Correct |
155 ms |
17904 KB |
Output is correct |
6 |
Correct |
153 ms |
17160 KB |
Output is correct |
7 |
Correct |
168 ms |
17440 KB |
Output is correct |
8 |
Correct |
127 ms |
13800 KB |
Output is correct |
9 |
Correct |
151 ms |
18824 KB |
Output is correct |
10 |
Correct |
173 ms |
17136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1264 KB |
Output is correct |
2 |
Correct |
9 ms |
1520 KB |
Output is correct |
3 |
Correct |
7 ms |
1068 KB |
Output is correct |
4 |
Correct |
7 ms |
1080 KB |
Output is correct |
5 |
Correct |
7 ms |
1068 KB |
Output is correct |
6 |
Correct |
7 ms |
1264 KB |
Output is correct |
7 |
Correct |
9 ms |
1264 KB |
Output is correct |
8 |
Correct |
10 ms |
1264 KB |
Output is correct |
9 |
Correct |
10 ms |
1520 KB |
Output is correct |
10 |
Correct |
12 ms |
2032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
137 ms |
14832 KB |
Output is correct - 120000 bits used |
2 |
Correct |
141 ms |
15344 KB |
Output is correct - 122000 bits used |
3 |
Correct |
153 ms |
16016 KB |
Output is correct - 125000 bits used |
4 |
Correct |
148 ms |
15856 KB |
Output is correct - 125000 bits used |
5 |
Correct |
155 ms |
15944 KB |
Output is correct - 125000 bits used |
6 |
Correct |
160 ms |
15904 KB |
Output is correct - 125000 bits used |
7 |
Correct |
156 ms |
15856 KB |
Output is correct - 124828 bits used |
8 |
Correct |
172 ms |
15856 KB |
Output is correct - 124910 bits used |
9 |
Correct |
151 ms |
15944 KB |
Output is correct - 125000 bits used |
10 |
Correct |
124 ms |
12528 KB |
Output is correct - 125000 bits used |