답안 #137823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137823 2019-07-28T10:04:40 Z mohammedehab2002 최후의 만찬 (IOI12_supper) C++11
0 / 100
138 ms 11072 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)
		{
			cur[arr[s.begin()->second]]={-1,-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);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 880 KB Output is correct
2 Incorrect 4 ms 880 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1520 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 91 ms 8944 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1040 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 107 ms 10232 KB Output isn't correct - not an optimal way
2 Incorrect 112 ms 10664 KB Output isn't correct - not an optimal way
3 Incorrect 115 ms 10848 KB Output isn't correct - not an optimal way
4 Incorrect 120 ms 10976 KB Output isn't correct - not an optimal way
5 Incorrect 115 ms 10920 KB Output isn't correct - not an optimal way
6 Incorrect 120 ms 10936 KB Output isn't correct - not an optimal way
7 Incorrect 119 ms 11064 KB Output isn't correct - not an optimal way
8 Incorrect 138 ms 11072 KB Output isn't correct - not an optimal way
9 Incorrect 118 ms 10992 KB Output isn't correct - not an optimal way
10 Incorrect 114 ms 10176 KB Output isn't correct - not an optimal way