답안 #912977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912977 2024-01-20T04:57:22 Z Faisal_Saqib 최후의 만찬 (IOI12_supper) C++17
50 / 100
347 ms 19460 KB
#pragma once
#include "advisor.h"
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;
/*
1	8	N≤5000 M=65000bits
2	9	N≤100000 M=2000000bits
3	9	N≤100000 M=1500bits K≤25000
4	35	N≤5000 M=10000bits
5	up to 39	N≤100000 M=1800000bits K≤25000

*/
void ComputeAdvice(int *c, int n, int k, int m)
{
	// cout<<"ASD\n";
	vector<int> pos[n];
	for(int j=0;j<n;j++)
		pos[j].push_back(1e9);
	for(int i=n-1;i>=0;i--)
		pos[c[i]].push_back(i);
	set<pair<int,int>> hap;
	map<int,int> color_to_index;
	for(int i=0;i<k;i++)
	{
		// cout<<"Hola "<<-pos[i].back()<<' '<<i<<endl;
		hap.insert({-pos[i].back(),i});
		color_to_index[i]=i;
	}
	int lg=log2(k);	
	int last=-1;
	for(int j=0;j<n;j++)
	{
		if(color_to_index.find(c[j])==color_to_index.end())
		{
			pos[c[j]].pop_back();
			auto it=*begin(hap);
			hap.erase(begin(hap));
			int npd=color_to_index[it.second];
			// cout<<"Rem "<<-it.first<<' '<<it.second<<" ind ";
			// cout<<npd<<endl;
			WriteAdvice((last==npd));
			for(int l=lg;l>=0 and last!=npd;l--)
			{
				if(npd&(1ll<<l))
				{
					WriteAdvice(1);	
				}
				else
				{
					WriteAdvice(0);
				}
			}
			last=npd;
			color_to_index.erase(it.second);
			// cout<<"Adding "<<pos[c[j]].back()<<' '<<c[j]<<' '<<npd<<endl;
			hap.insert({-pos[c[j]].back(),c[j]});
			color_to_index[c[j]]=npd;
		}
		else
		{
			hap.erase({-pos[c[j]].back(),c[j]});
			pos[c[j]].pop_back();
			hap.insert({-pos[c[j]].back(),c[j]});
		}
	}	
}

#pragma once
#include "assistant.h"
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;
/*
1	8	N≤5000 M=65000bits
2	9	N≤100000 M=2000000bits
3	9	N≤100000 M=1500bits K≤25000
4	35	N≤5000 M=10000bits
5	up to 39	N≤100000 M=1800000bits K≤25000

*/
void Assist(unsigned char *a, int n, int k, int r)
{
	vector<int> ans;
	set<int> hap;
	for(int i=0;i<k;i++)
	{
		hap.insert(i);
		ans.push_back(i);
	}
	int lg=log2(k);
	int p=0;
	int last=-1;
	for(int j=0;j<n;j++)
	{
		int x=GetRequest();
		if(hap.find(x)!=hap.end())
			continue;
		int ind=0;
		int dop=a[p];
		if(dop)
			ind=last;
		p++;
		for(int l=lg;l>=0 and dop==0;l--)
		{
			ind*=2;
			ind+=(a[p]);
			p++;
		}
		PutBack(ans[ind]);
		last=ind;
		hap.erase(ans[ind]);
		hap.insert(x);
		ans[ind]=x;
	}
}

Compilation message

advisor.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~

assistant.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 780 KB Output is correct
2 Correct 1 ms 780 KB Output is correct
3 Correct 2 ms 800 KB Output is correct
4 Correct 3 ms 1104 KB Output is correct
5 Correct 4 ms 1368 KB Output is correct
6 Correct 8 ms 1112 KB Output is correct
7 Correct 5 ms 1352 KB Output is correct
8 Correct 9 ms 1396 KB Output is correct
9 Correct 8 ms 1576 KB Output is correct
10 Correct 9 ms 1440 KB Output is correct
11 Correct 9 ms 1392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 2368 KB Output is correct
2 Correct 78 ms 7108 KB Output is correct
3 Correct 308 ms 19460 KB Output is correct
4 Correct 154 ms 10428 KB Output is correct
5 Correct 149 ms 11220 KB Output is correct
6 Correct 199 ms 13432 KB Output is correct
7 Correct 226 ms 16276 KB Output is correct
8 Correct 227 ms 15884 KB Output is correct
9 Correct 87 ms 10544 KB Output is correct
10 Correct 268 ms 18028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 237 ms 13752 KB Output is correct
2 Correct 266 ms 17000 KB Output is correct
3 Correct 327 ms 17004 KB Output is correct
4 Correct 347 ms 16536 KB Output is correct
5 Correct 200 ms 15196 KB Output is correct
6 Correct 276 ms 16900 KB Output is correct
7 Correct 264 ms 17124 KB Output is correct
8 Correct 270 ms 17988 KB Output is correct
9 Correct 213 ms 15540 KB Output is correct
10 Correct 334 ms 16888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1364 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 255 ms 16240 KB Output is partially correct - 693251 bits used
2 Correct 314 ms 16708 KB Output is partially correct - 691863 bits used
3 Correct 285 ms 17100 KB Output is partially correct - 689168 bits used
4 Correct 295 ms 17408 KB Output is partially correct - 689212 bits used
5 Correct 294 ms 17108 KB Output is partially correct - 687469 bits used
6 Correct 269 ms 17076 KB Output is partially correct - 688217 bits used
7 Correct 287 ms 17216 KB Output is partially correct - 688881 bits used
8 Correct 294 ms 17032 KB Output is partially correct - 689601 bits used
9 Correct 252 ms 17216 KB Output is partially correct - 690047 bits used
10 Correct 294 ms 17852 KB Output is partially correct - 851808 bits used