답안 #348439

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
348439 2021-01-15T02:40:53 Z daniel920712 최후의 만찬 (IOI12_supper) C++14
43 / 100
329 ms 18004 KB
#include "advisor.h"
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#include <stdio.h>
using namespace std;
int where[1000005];
int Next[1000005];
vector < int > when[100005];
map < int , int > how;
void ComputeAdvice(int *C, int N, int K, int M) 
{
	int t=0,now=1,xx,i,j;
	while(now<K)
	{
		now*=2;
		t++;
	}
	
	for(i=0;i<N;i++) when[C[i]].push_back(i);
	for(i=0;i<N;i++) when[i].push_back(i+N);
	for(i=0;i<N;i++) Next[i]=*upper_bound(when[C[i]].begin(),when[C[i]].end(),i);
	for(i=0;i<K;i++) 
	{
		where[i]=i;
		how[when[i][0]]=i;
	}
	for(i=K;i<N;i++) where[i]=-1;
	for(i=0;i<N;i++)
	{
		if(how.find(i)!=how.end()) how.erase(i);
		if(where[C[i]]==-1)
		{
			xx=where[prev(how.end())->second];
			for(j=0;j<t;j++) 
			{
				if(xx&(1<<j)) WriteAdvice(1);
				else WriteAdvice(0);
			}
			where[C[i]]=xx;
			where[prev(how.end())->second]=-1;
			how.erase(prev(how.end()));
		}
		how[Next[i]]=C[i]; 
	}

}
#include "assistant.h"
int where2[1000005];
int what[1000005];
void Assist(unsigned char *A, int N, int K, int R) {

    int t=0,now=1,xx=0,how,tt=0,i,j;
	while(now<K)
	{
		now*=2;
		t++;
	}
	for(i=0;i<K;i++) 
	{
		where2[i]=i;
		what[i]=i;
	}
	for(i=K;i<N;i++) where2[i]=-1;
	for(i=0;i<N;i++)
	{
		how=GetRequest();
		if(where2[how]==-1)
		{
			xx=0;
			for(j=0;j<t;j++) xx+=A[j+tt]*(1<<j);
			tt+=t;
			PutBack(what[xx]);
			where2[how]=xx;
			where2[what[xx]]=-1;
			what[xx]=how;
			
		}
	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3364 KB Output is correct
2 Correct 2 ms 3044 KB Output is correct
3 Correct 4 ms 3304 KB Output is correct
4 Correct 5 ms 3472 KB Output is correct
5 Correct 5 ms 3348 KB Output is correct
6 Correct 11 ms 3764 KB Output is correct
7 Correct 6 ms 3492 KB Output is correct
8 Correct 13 ms 3708 KB Output is correct
9 Correct 13 ms 3680 KB Output is correct
10 Correct 12 ms 3800 KB Output is correct
11 Correct 12 ms 3656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 4100 KB Output is correct
2 Correct 95 ms 8484 KB Output is correct
3 Correct 287 ms 17216 KB Output is correct
4 Correct 188 ms 13580 KB Output is correct
5 Correct 262 ms 15580 KB Output is correct
6 Correct 273 ms 15588 KB Output is correct
7 Correct 258 ms 15520 KB Output is correct
8 Correct 264 ms 15876 KB Output is correct
9 Correct 142 ms 12708 KB Output is correct
10 Correct 236 ms 15616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 193 ms 12876 KB Output is correct
2 Correct 260 ms 15660 KB Output is correct
3 Correct 252 ms 15608 KB Output is correct
4 Correct 229 ms 15044 KB Output is correct
5 Correct 195 ms 13928 KB Output is correct
6 Correct 246 ms 15852 KB Output is correct
7 Correct 244 ms 15400 KB Output is correct
8 Correct 314 ms 18004 KB Output is correct
9 Correct 167 ms 13764 KB Output is correct
10 Correct 250 ms 15572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 3300 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 287 ms 15116 KB Output is partially correct - 772365 bits used
2 Correct 277 ms 15192 KB Output is partially correct - 742095 bits used
3 Correct 256 ms 15504 KB Output is partially correct - 712470 bits used
4 Correct 254 ms 15084 KB Output is partially correct - 712005 bits used
5 Correct 255 ms 15084 KB Output is partially correct - 710610 bits used
6 Correct 248 ms 14932 KB Output is partially correct - 712155 bits used
7 Correct 254 ms 15056 KB Output is partially correct - 711090 bits used
8 Correct 250 ms 14936 KB Output is partially correct - 713340 bits used
9 Correct 253 ms 15076 KB Output is partially correct - 712830 bits used
10 Correct 329 ms 17732 KB Output is partially correct - 1117620 bits used