답안 #122169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122169 2019-06-27T18:24:22 Z TadijaSebez 최후의 만찬 (IOI12_supper) C++11
100 / 100
87 ms 12400 KB
#include <bits/stdc++.h>
using namespace std;
#include "advisor.h"
#define pb push_back
const int N=100050;
int last[N],go[N];
bool in[N];
pair<int,pair<int,int>> l[N];
bool was[2*N];
void ComputeAdvice(int *C, int n, int k, int M)
{
	priority_queue<pair<int,pair<int,int>>> pq,rq;
	for(int i=0;i<n;i++) last[i]=n;
	for(int i=n-1;i>=0;i--) go[i]=last[C[i]],last[C[i]]=i;
	for(int i=0;i<k;i++)
	{
		pq.push({last[i],{i,i}});
		in[i]=1;
		l[i]={last[i],{i,i}};
	}
	for(int i=0;i<n;i++)
	{
		while(pq.size() && rq.size() && pq.top()==rq.top()) pq.pop(),rq.pop();
		if(in[C[i]])
		{
			rq.push(l[C[i]]);
			l[C[i]]={go[i],{C[i],i+k}};
			pq.push(l[C[i]]);
		}
		else
		{
			was[pq.top().second.second]=1;
			in[pq.top().second.first]=0;
			rq.push(pq.top());
			l[C[i]]={go[i],{C[i],i+k}};
			pq.push(l[C[i]]);
			in[C[i]]=1;
		}
	}
	for(int i=0;i<n+k;i++) WriteAdvice((unsigned char)was[i]);
}
#include <bits/stdc++.h>
using namespace std;
#include "assistant.h"
#define pb push_back
const int N=100050;
void Assist(unsigned char *A, int n, int k, int R)
{
	vector<int> del;
	vector<int> in(n,0);
	for(int i=0;i<k;i++) in[i]=1;
	for(int i=0;i<k;i++) if(A[i]) del.pb(i);
	for(int i=0;i<n;i++)
	{
		int x=GetRequest();
		if(!in[x])
		{
			PutBack(del.back());
			in[del.back()]=0;
			in[x]=1;
			del.pop_back();
		}
		if(A[i+k]) del.pb(x);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 776 KB Output is correct
2 Correct 4 ms 776 KB Output is correct
3 Correct 4 ms 780 KB Output is correct
4 Correct 5 ms 1040 KB Output is correct
5 Correct 7 ms 1056 KB Output is correct
6 Correct 7 ms 1024 KB Output is correct
7 Correct 7 ms 1352 KB Output is correct
8 Correct 7 ms 1024 KB Output is correct
9 Correct 7 ms 1280 KB Output is correct
10 Correct 7 ms 1536 KB Output is correct
11 Correct 7 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1592 KB Output is correct
2 Correct 38 ms 6008 KB Output is correct
3 Correct 87 ms 11736 KB Output is correct
4 Correct 70 ms 8688 KB Output is correct
5 Correct 74 ms 8792 KB Output is correct
6 Correct 76 ms 9328 KB Output is correct
7 Correct 81 ms 11432 KB Output is correct
8 Correct 72 ms 8672 KB Output is correct
9 Correct 71 ms 8680 KB Output is correct
10 Correct 84 ms 11240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 70 ms 9184 KB Output is correct
2 Correct 81 ms 11176 KB Output is correct
3 Correct 82 ms 11232 KB Output is correct
4 Correct 82 ms 11232 KB Output is correct
5 Correct 81 ms 12256 KB Output is correct
6 Correct 84 ms 11232 KB Output is correct
7 Correct 79 ms 11248 KB Output is correct
8 Correct 82 ms 9696 KB Output is correct
9 Correct 74 ms 12400 KB Output is correct
10 Correct 81 ms 11240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1272 KB Output is correct
2 Correct 8 ms 1280 KB Output is correct
3 Correct 7 ms 1536 KB Output is correct
4 Correct 8 ms 1064 KB Output is correct
5 Correct 7 ms 1076 KB Output is correct
6 Correct 7 ms 1280 KB Output is correct
7 Correct 7 ms 1280 KB Output is correct
8 Correct 8 ms 1280 KB Output is correct
9 Correct 7 ms 1280 KB Output is correct
10 Correct 7 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 11232 KB Output is correct - 120000 bits used
2 Correct 81 ms 11232 KB Output is correct - 122000 bits used
3 Correct 84 ms 11232 KB Output is correct - 125000 bits used
4 Correct 84 ms 11064 KB Output is correct - 125000 bits used
5 Correct 82 ms 11112 KB Output is correct - 125000 bits used
6 Correct 79 ms 11232 KB Output is correct - 125000 bits used
7 Correct 81 ms 10976 KB Output is correct - 124828 bits used
8 Correct 84 ms 11144 KB Output is correct - 124910 bits used
9 Correct 83 ms 11232 KB Output is correct - 125000 bits used
10 Correct 84 ms 9696 KB Output is correct - 125000 bits used