답안 #912878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912878 2024-01-20T03:53:17 Z Faisal_Saqib 최후의 만찬 (IOI12_supper) C++17
43 / 100
324 ms 20260 KB
#pragma once
#include "advisor.h"
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;
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);	
	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;
			for(int l=lg;l>=0;l--)
			{
				if(npd&(1ll<<l))
				{
					WriteAdvice(1);	
				}
				else
				{
					WriteAdvice(0);
				}
			}
			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;
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;
	for(int j=0;j<n;j++)
	{
		int x=GetRequest();
		if(hap.find(x)!=hap.end())
			continue;
		int ind=0;
		for(int l=lg;l>=0;l--)
		{
			ind*=2;
			ind+=(a[p]);
			p++;
		}
		PutBack(ans[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 784 KB Output is correct
2 Correct 0 ms 780 KB Output is correct
3 Correct 1 ms 796 KB Output is correct
4 Correct 3 ms 1084 KB Output is correct
5 Correct 4 ms 1204 KB Output is correct
6 Correct 8 ms 1408 KB Output is correct
7 Correct 6 ms 1100 KB Output is correct
8 Correct 10 ms 1432 KB Output is correct
9 Correct 10 ms 1428 KB Output is correct
10 Correct 12 ms 1552 KB Output is correct
11 Correct 9 ms 1580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 2232 KB Output is correct
2 Correct 84 ms 7420 KB Output is correct
3 Correct 324 ms 20260 KB Output is correct
4 Correct 185 ms 13044 KB Output is correct
5 Correct 224 ms 15000 KB Output is correct
6 Correct 308 ms 15868 KB Output is correct
7 Correct 275 ms 16936 KB Output is correct
8 Correct 267 ms 17036 KB Output is correct
9 Correct 115 ms 12060 KB Output is correct
10 Correct 304 ms 17892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 12980 KB Output is correct
2 Correct 277 ms 17124 KB Output is correct
3 Correct 241 ms 17320 KB Output is correct
4 Correct 262 ms 17128 KB Output is correct
5 Correct 209 ms 15172 KB Output is correct
6 Correct 278 ms 17152 KB Output is correct
7 Correct 253 ms 17128 KB Output is correct
8 Correct 308 ms 19596 KB Output is correct
9 Correct 173 ms 15988 KB Output is correct
10 Correct 299 ms 17416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1356 KB Error - advice is too long
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 266 ms 15728 KB Output is partially correct - 772365 bits used
2 Correct 284 ms 15944 KB Output is partially correct - 742095 bits used
3 Correct 256 ms 16000 KB Output is partially correct - 712470 bits used
4 Correct 238 ms 16016 KB Output is partially correct - 712005 bits used
5 Correct 269 ms 15916 KB Output is partially correct - 710610 bits used
6 Correct 260 ms 16384 KB Output is partially correct - 712155 bits used
7 Correct 228 ms 16064 KB Output is partially correct - 711090 bits used
8 Correct 243 ms 16456 KB Output is partially correct - 713340 bits used
9 Correct 233 ms 16280 KB Output is partially correct - 712830 bits used
10 Correct 301 ms 18444 KB Output is partially correct - 1117620 bits used