답안 #349826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
349826 2021-01-18T13:11:14 Z juggernaut 최후의 만찬 (IOI12_supper) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include"advisor.h"
using namespace std;
int const MAXN=100000;
struct Color{
	int id;
	int np;
	Color(){}
	Color(int _id,int _np){
		id=_id;
		np=_np;
	}
};
bool operator<(Color const &a,Color const &b){
	return(a.np<b.np);
}
int next[MAXN];
int position[MAXN];
bool in_scaffold[MAXN];
priority_queue<Color>coda;
int solution[MAXN];
queue<int>events[MAXN];
int accumulated=0;
int counter=0;
void ComputeAdvice(int *d,int n,int k,int m){
	for(int i=0;i<n;i++)position[i]=n;
	for(int i=n-1;i>=0;i--)next[i]=position[d[i]],position[d[i]]=i;
	for(int j=0;j<k;j++){
		in_scaffold[j]=1;
		coda.push(Color(j,position[j]));
	}
	for(int i=0;i<n;i++){
		int color=d[i];
		if(in_scaffold[color]){
			coda.push(Color(color,next[i]));
			solution[i]=-1;
			events[color].push(1);
			continue;
		}		
		Color useless=coda.top();
		coda.pop();
		in_scaffold[useless.id]=0;
		coda.push(Color(color,next[i]));
		in_scaffold[color]=1;
		solution[i]=useless.id;
		events[useless.id].push(0);
		events[color].push(1);
	}
	for(int j=0;j<k;j++){
		if(events[j].empty()){
			WriteAdvice(0);
			continue;
		}
		if(events[j].front()==0){
			events[j].pop();
			WriteAdvice(0);
		}else WriteAdvice(1);
	}
	for(int i=0;i<n;i++){	
		int color=d[i];
		assert(events[color].front()==1);
		events[color].pop();
		if(events[color].empty()){
			WriteAdvice(0);
			continue;
		}
		if(events[color].front()==0){
			events[color].pop();
		    WriteAdvice(0);
		}else WriteAdvice(1);
	}
}

#include<bits/stdc++.h>
#include"assistant.h"
using namespace std;
int const MAXN=100000;
bool in_the_scaffold[MAXN];
queue<int>passive;
void Assist(unsigned char *real_advice,int n,int k,int l){
	for(int i=0;i<k;i++){
		in_the_scaffold[i]=1;
		if(real_advice[i]==0)passive.push(i);
	}
	for(int i=0;i<n;i++){
		int color=GetRequest();
		if (!in_the_scaffold[color]){
			in_the_scaffold[passive.front()]=0;
			in_the_scaffold[color]=1;
			PutBack(passive.front());
			passive.pop();	
		}
		if(real_advice[k+i]==0)passive.push(color);
	}	
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:27:25: error: reference to 'next' is ambiguous
   27 |  for(int i=n-1;i>=0;i--)next[i]=position[d[i]],position[d[i]]=i;
      |                         ^~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:66,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from advisor.cpp:1:
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
advisor.cpp:17:5: note:                 'int next [100000]'
   17 | int next[MAXN];
      |     ^~~~
advisor.cpp:35:19: error: expected primary-expression before '(' token
   35 |    coda.push(Color(color,next[i]));
      |                   ^
advisor.cpp:35:26: error: reference to 'next' is ambiguous
   35 |    coda.push(Color(color,next[i]));
      |                          ^~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:66,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from advisor.cpp:1:
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
advisor.cpp:17:5: note:                 'int next [100000]'
   17 | int next[MAXN];
      |     ^~~~
advisor.cpp:43:18: error: expected primary-expression before '(' token
   43 |   coda.push(Color(color,next[i]));
      |                  ^
advisor.cpp:43:25: error: reference to 'next' is ambiguous
   43 |   coda.push(Color(color,next[i]));
      |                         ^~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:66,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from advisor.cpp:1:
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
advisor.cpp:17:5: note:                 'int next [100000]'
   17 | int next[MAXN];
      |     ^~~~