# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
718888 |
2023-04-05T04:59:17 Z |
lam |
Last supper (IOI12_supper) |
C++14 |
|
513 ms |
14748 KB |
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
#define ff first
#define ss second
const int maxn = 2e5 + 10;
map<int,int> mp;
int a[maxn],pre[maxn],id[maxn],type[maxn];
int xoa[maxn];
void ComputeAdvice(int *C, int N, int K, int M) {
int n,k,m;
n=N; k=K;
for (int i=1; i<=k; i++) a[i]=i-1;
for (int i=1; i<=n; i++) a[i+k] = C[i-1];
mp.clear();
m=n+k;
for (int i=m; i>=1; i--)
{
if (!mp[a[i]]) pre[i]=n+1;
else pre[i]=mp[a[i]];
mp[a[i]]=i;
}
fill_n(id,m+1,0);
fill_n(type,m+1,0);
multiset<ii> ms;
for (int i=1; i<=k; i++) ms.insert({pre[i],i}),id[a[i]]=i;
for (int i=k+1; i<=m; i++)
{
if (id[a[i]]!=0)
{
int x=id[a[i]];
ms.erase(ms.find({pre[x],x}));
type[x] = 1;
id[a[i]]=i;
ms.insert({pre[i],i});
continue;
}
auto it = ms.end(); it--;
xoa[i] = it->ss;
ms.erase(it);
cerr<<i<<" := xoa "<<a[xoa[i]]<<endl;
ms.insert({pre[i],i});
type[xoa[i]] = 2;
id[a[xoa[i]]] = 0;
id[a[i]] = i;
}
for (int i=0; i<n; i++) if (id[i]!=0) type[id[i]] = 1;
// for (int i=1; i<=m; i++) cerr<<type[i]<<' '; cerr<<endl;
for (int i=1; i<=m; i++) if (type[i]==2) WriteAdvice(1);
else WriteAdvice(0);
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
typedef pair<int,int> ii;
#define ff first
#define ss second
int n,m,k;
int type[maxn];
void Assist(unsigned char *A, int N, int K, int R) {
n=N;
k=K;
m=n+k;
multiset<ii> ms;
fill_n(type,m+1,0);
// for (int i=0; i<R; i++) cerr<<A[i]; cerr<<endl;
for (int i=1; i<=k; i++)
{
char x = A[i-1];
if (x==1) type[i-1] = 2;
else type[i-1] = 1;
ms.insert({type[i-1],i-1});
};
for (int i=1; i<=n; i++)
{
int x=GetRequest();
char c = A[k+i-1];
if (type[x]!=0)
{
ms.erase(ms.find({type[x],x}));
int last = type[x];
type[x] = (c==1)+1;
if (last==2) type[x] = 2;
ms.insert({type[x],x});
}
else
{
auto r = ms.end(); r--;
// for (auto j:ms) cerr<<j.ff<<','<<j.ss<<" : "; cerr<<endl;
// cerr<<r->ff<<" - "<<r->ss<<endl;
PutBack(r->ss);
type[r->ss] = 0;
ms.erase(r);
type[x] = (c==1)+1;
ms.insert({type[x],x});
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
524 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
1696 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
366 ms |
10572 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
1044 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
436 ms |
12504 KB |
Output isn't correct - not an optimal way |
2 |
Incorrect |
441 ms |
12908 KB |
Output isn't correct - not an optimal way |
3 |
Incorrect |
464 ms |
13476 KB |
Output isn't correct - not an optimal way |
4 |
Incorrect |
449 ms |
13240 KB |
Output isn't correct - not an optimal way |
5 |
Incorrect |
446 ms |
13232 KB |
Output isn't correct - not an optimal way |
6 |
Incorrect |
446 ms |
13116 KB |
Output isn't correct - not an optimal way |
7 |
Incorrect |
453 ms |
13364 KB |
Output isn't correct - not an optimal way |
8 |
Incorrect |
443 ms |
13188 KB |
Output isn't correct - not an optimal way |
9 |
Incorrect |
431 ms |
13496 KB |
Output isn't correct - not an optimal way |
10 |
Incorrect |
513 ms |
14748 KB |
Output isn't correct - not an optimal way |