답안 #137829

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137829 2019-07-28T10:33:05 Z mohammedehab2002 최후의 만찬 (IOI12_supper) C++11
0 / 100
139 ms 11208 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])
		{
			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 964 KB Output is correct
2 Incorrect 4 ms 988 KB Output isn't correct - not an optimal way
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 1776 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 100 ms 8944 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 1264 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 115 ms 10224 KB Output isn't correct - not an optimal way
2 Incorrect 120 ms 10736 KB Output isn't correct - not an optimal way
3 Incorrect 129 ms 10992 KB Output isn't correct - not an optimal way
4 Incorrect 128 ms 11064 KB Output isn't correct - not an optimal way
5 Incorrect 129 ms 10936 KB Output isn't correct - not an optimal way
6 Incorrect 130 ms 10992 KB Output isn't correct - not an optimal way
7 Incorrect 139 ms 11064 KB Output isn't correct - not an optimal way
8 Incorrect 133 ms 11208 KB Output isn't correct - not an optimal way
9 Incorrect 131 ms 10904 KB Output isn't correct - not an optimal way
10 Incorrect 127 ms 10248 KB Output isn't correct - not an optimal way