Submission #137818

# Submission time Handle Problem Language Result Execution time Memory
137818 2019-07-28T09:56:41 Z mohammedehab2002 Last supper (IOI12_supper) C++11
0 / 100
127 ms 12432 KB
#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)
		s.erase(s.begin());
		else
		{
			s.erase(cur[arr[i]]);
			advice[cur[arr[i]].second]=1;
			cur[arr[i]]={nex[i],i};
			s.insert(cur[arr[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])
		continue;
		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);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 860 KB Output is correct
2 Incorrect 4 ms 884 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1776 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 9976 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1216 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 11984 KB Output isn't correct - not an optimal way
2 Incorrect 112 ms 12016 KB Output isn't correct - not an optimal way
3 Incorrect 119 ms 12280 KB Output isn't correct - not an optimal way
4 Incorrect 121 ms 12280 KB Output isn't correct - not an optimal way
5 Incorrect 118 ms 12376 KB Output isn't correct - not an optimal way
6 Incorrect 115 ms 12432 KB Output isn't correct - not an optimal way
7 Incorrect 117 ms 12272 KB Output isn't correct - not an optimal way
8 Incorrect 118 ms 12344 KB Output isn't correct - not an optimal way
9 Incorrect 127 ms 12304 KB Output isn't correct - not an optimal way
10 Incorrect 102 ms 11384 KB Output isn't correct - not an optimal way