답안 #341927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341927 2020-12-31T13:28:24 Z ogibogi2004 최후의 만찬 (IOI12_supper) C++14
0 / 100
215 ms 21256 KB
#include "advisor.h"
#include<bits/stdc++.h>
using namespace std;
#define floor sdfds
const int MAXN=2e5+6;
int nxt[MAXN],pr[MAXN];
bool on_floor[MAXN];
vector<int>v[MAXN];
set<pair<int,int> >floor;
bool t[MAXN];
void ComputeAdvice(int *C, int N, int K, int M) {
	vector<int>gg;
	for(int i=0;i<K;i++)
	{
		gg.push_back(i);
	}
	for(int i=0;i<N;i++)
	{
		gg.push_back(C[i]);
	}
	for(int i=0;i<gg.size();i++)
	{
		v[gg[i]].push_back(i);
	}
	memset(pr,-1,sizeof(pr));
	memset(nxt,-1,sizeof(nxt));
	for(int i=0;i<MAXN;i++)
	{
		for(int j=0;j<v[i].size();j++)
		{
			if(j!=0)pr[v[i][j]]=v[i][j-1];
			if(j!=v[i].size()-1)
			{
				nxt[v[i][j]]=v[i][j+1];
			}
		}
	}
	for(int i=0;i<gg.size();i++)
	{
		if(floor.size()<K)
		{
			if(nxt[i]!=-1)floor.insert({nxt[i],i});
			else floor.insert({MAXN,i});
			on_floor[gg[i]]=1;
		}
		else
		{
			if(on_floor[gg[i]])
			{
				t[pr[i]]=1;
				floor.erase({i,pr[i]});
				if(nxt[i]!=-1)floor.insert({nxt[i],i});
				else floor.insert({MAXN,i});
			}
			else
			{
				auto p=(*floor.begin());
				floor.erase(p);
				on_floor[gg[p.second]]=0;
				on_floor[gg[i]]=1;
				if(nxt[i]!=-1)floor.insert({nxt[i],i});
				else floor.insert({MAXN,i});
			}
		}
	}
	for(int i=0;i<gg.size();i++)
	{
		WriteAdvice(t[i]);
	}
}
#include "assistant.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+6;
set<pair<int,int> >scaffold;
set<int>s1;
map<int,int>mp;
set<pair<int,int> >for_removing;
int color[MAXN];
void Assist(unsigned char *A, int N, int K, int R) {
	for(int i=0;i<K;i++)
	{
		scaffold.insert({i,i});
		s1.insert(i);
		mp[i]=i;
		if(A[i]==0)
		{
			for_removing.insert({i,i});
		}
	}
	for(int i=0;i<N;i++)
	{
		int c=GetRequest();
		if(s1.find(c)!=s1.end())
		{
			scaffold.erase({mp[c],c});
			mp[c]=i+K;
			scaffold.insert({mp[c],c});
			if(A[i+K]==0)for_removing.insert({mp[c],c});
		}
		else
		{
			auto xd=(*for_removing.begin());
			s1.erase(xd.second);
			for_removing.erase(xd);
			PutBack(xd.second);
			scaffold.erase(xd);
			mp[c]=i;
			scaffold.insert({mp[c],c});
			if(A[i+K]==0)for_removing.insert({mp[c],c});
		}
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=0;i<gg.size();i++)
      |              ~^~~~~~~~~~
advisor.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for(int j=0;j<v[i].size();j++)
      |               ~^~~~~~~~~~~~
advisor.cpp:33:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    if(j!=v[i].size()-1)
      |       ~^~~~~~~~~~~~~~~
advisor.cpp:39:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i=0;i<gg.size();i++)
      |              ~^~~~~~~~~~
advisor.cpp:41:18: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |   if(floor.size()<K)
      |                  ^
advisor.cpp:67:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |  for(int i=0;i<gg.size();i++)
      |              ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 7260 KB Output isn't correct - not an optimal way
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 8172 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 100 ms 16804 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 7592 KB Error - Putting back a color when it is already on the scaffold
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 120 ms 17940 KB Error - Putting back a color when it is already on the scaffold
2 Incorrect 127 ms 18812 KB Error - Putting back a color when it is already on the scaffold
3 Incorrect 131 ms 19592 KB Error - Putting back a color when it is already on the scaffold
4 Incorrect 127 ms 19208 KB Error - Putting back a color when it is already on the scaffold
5 Incorrect 129 ms 19500 KB Error - Putting back a color when it is already on the scaffold
6 Incorrect 128 ms 19208 KB Error - Putting back a color when it is already on the scaffold
7 Incorrect 129 ms 19212 KB Error - Putting back a color when it is already on the scaffold
8 Incorrect 129 ms 19212 KB Error - Putting back a color when it is already on the scaffold
9 Incorrect 130 ms 19336 KB Error - Putting back a color when it is already on the scaffold
10 Incorrect 215 ms 21256 KB Error - Putting back a color that is not on the scaffold