답안 #94126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94126 2019-01-16T10:50:36 Z fjzzq2002 최후의 만찬 (IOI12_supper) C++14
100 / 100
76 ms 10712 KB
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define SZ 222222
typedef pair<int,int> pii;
#define fi first
#define se second
int d[SZ],e[SZ],f[SZ],ns[SZ],ts[SZ];
void ComputeAdvice(int *C,int N,int K,int M)
{
	for(int i=0;i<N;++i) f[i]=-1,ts[i]=2e9;
	for(int i=0;i<N+K;++i)
	{
		if(i<K) d[i]=i;
		else d[i]=C[i-K];
	}
	for(int i=N+K-1;i>=0;--i)
		ns[i]=ts[d[i]],ts[d[i]]=i;
	priority_queue<pii> pq,eq;
	for(int i=0;i<K;++i)
		pq.push(pii(2e9+i,-1));
	for(int i=0;i<N+K;++i)
	{
		while(pq.size()&&eq.size()&&pq.top()==eq.top())
			pq.pop(),eq.pop();
		int x=d[i];
		if(~f[x])
			eq.push(pii(i,f[x]));
		else
		{
			auto w=pq.top(); pq.pop();
			if(~w.se) e[w.se]=1,f[d[w.se]]=-1;
		}
		f[x]=i; pq.push(pii(ns[i],i));
	}
	for(int i=0;i<N+K;++i)
		WriteAdvice(e[i]);
}
#include "assistant.h"
#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
#define SZ 222222
typedef pair<int,int> pii;
#define pb push_back
#define fi first
#define se second
bool in[SZ];
void Assist(unsigned char *A, int N, int K, int R)
{
	vector<int> gg;
	for(int i=0;i<K;++i)
	{
		in[i]=1;
		if(A[i]) gg.pb(i);
	}
	for(int i=K;i<N+K;++i)
	{
		int u=GetRequest();
		if(!in[u])
		{
			if(!gg.size()) throw "GG";
			int w=gg.back();
			gg.pop_back();
			PutBack(w);
			in[w]=0;
		}
		in[u]=1;
		if(A[i]) gg.pb(u);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 836 KB Output is correct
2 Correct 4 ms 836 KB Output is correct
3 Correct 4 ms 784 KB Output is correct
4 Correct 5 ms 1008 KB Output is correct
5 Correct 5 ms 1088 KB Output is correct
6 Correct 3 ms 1080 KB Output is correct
7 Correct 7 ms 1272 KB Output is correct
8 Correct 7 ms 1308 KB Output is correct
9 Correct 7 ms 1264 KB Output is correct
10 Correct 7 ms 1264 KB Output is correct
11 Correct 7 ms 1264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1728 KB Output is correct
2 Correct 34 ms 5096 KB Output is correct
3 Correct 76 ms 10480 KB Output is correct
4 Correct 57 ms 8688 KB Output is correct
5 Correct 61 ms 8624 KB Output is correct
6 Correct 66 ms 8768 KB Output is correct
7 Correct 72 ms 10208 KB Output is correct
8 Correct 61 ms 8032 KB Output is correct
9 Correct 56 ms 8384 KB Output is correct
10 Correct 73 ms 9952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 7136 KB Output is correct
2 Correct 72 ms 9888 KB Output is correct
3 Correct 74 ms 9952 KB Output is correct
4 Correct 71 ms 9952 KB Output is correct
5 Correct 68 ms 10712 KB Output is correct
6 Correct 73 ms 9944 KB Output is correct
7 Correct 73 ms 9952 KB Output is correct
8 Correct 72 ms 9200 KB Output is correct
9 Correct 70 ms 10360 KB Output is correct
10 Correct 71 ms 9952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1008 KB Output is correct
2 Correct 7 ms 1264 KB Output is correct
3 Correct 5 ms 1092 KB Output is correct
4 Correct 5 ms 1008 KB Output is correct
5 Correct 6 ms 1328 KB Output is correct
6 Correct 5 ms 1264 KB Output is correct
7 Correct 6 ms 1264 KB Output is correct
8 Correct 6 ms 1264 KB Output is correct
9 Correct 7 ms 1264 KB Output is correct
10 Correct 8 ms 1520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 8936 KB Output is correct - 120000 bits used
2 Correct 70 ms 9184 KB Output is correct - 122000 bits used
3 Correct 74 ms 8936 KB Output is correct - 125000 bits used
4 Correct 73 ms 8928 KB Output is correct - 125000 bits used
5 Correct 71 ms 8680 KB Output is correct - 125000 bits used
6 Correct 73 ms 8928 KB Output is correct - 125000 bits used
7 Correct 73 ms 8672 KB Output is correct - 124828 bits used
8 Correct 73 ms 8928 KB Output is correct - 124910 bits used
9 Correct 72 ms 8928 KB Output is correct - 125000 bits used
10 Correct 72 ms 8232 KB Output is correct - 125000 bits used