답안 #4740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
4740 2013-12-26T00:16:57 Z cki86201 최후의 만찬 (IOI12_supper) C++
컴파일 오류
0 ms 0 KB
#include"advisor.h"
#include<queue>
using namespace std;

typedef pair<int,int> Pi;
#define X first
#define Y second
priority_queue <Pi> pq;

int next[100010],now[100010];
bool chk1[100010],chk2[100010],here[100010];

void ComputeAdvice(int *C, int N, int K, int M){
	int i;
	for(i=0;i<N;i++)now[i]=N;
	for(i=N-1;i>=0;i--)next[i]=now[C[i]],now[C[i]]=i;
	for(i=0;i<K;i++)pq.push(Pi(now[i],i)),here[i]=1;
	for(i=0;i<N;i++)now[i]=-1;
	for(i=0;i<N;i++){
		if(!here[C[i]]){
			Pi t=pq.top();
			if(now[t.Y]==-1)chk1[t.Y]=1;
			else chk2[now[t.Y]]=1;
			pq.pop();
			here[C[i]]=1,here[t.Y]=0;
		}
		pq.push(Pi(next[i],C[i]));
		now[C[i]]=i;
	}
	for(i=0;i<K;i++)WriteAdvice(chk1[i]);
	for(i=0;i<N;i++)WriteAdvice(chk2[i]);
}
#include"assistant.h"

int pos[100010],l;
bool in[100010];

void Assist(unsigned char *A, int N, int K, int R){
	int i;
	for(i=0;i<K;i++){
		if(A[i])pos[++l]=i;
		in[i]=1;
	}
	for(i=0;i<N;i++){
		int t=GetRequest();
		if(!in[t]){
			PutBack(pos[l]);
			in[t]=1,in[pos[l--]]=0;
		}
		if(A[i+K])pos[++l]=t;
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:16:21: error: reference to 'next' is ambiguous
  for(i=N-1;i>=0;i--)next[i]=now[C[i]],now[C[i]]=i;
                     ^~~~
advisor.cpp:10:5: note: candidates are: int next [100010]
 int next[100010],now[100010];
     ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/deque:60,
                 from /usr/include/c++/7/queue:60,
                 from advisor.cpp:2:
/usr/include/c++/7/bits/stl_iterator_base_funcs.h:208:5: note:                 template<class _ForwardIterator> _ForwardIterator std::next(_ForwardIterator, typename std::iterator_traits<_Iter>::difference_type)
     next(_ForwardIterator __x, typename
     ^~~~
advisor.cpp:27:13: error: expected primary-expression before '(' token
   pq.push(Pi(next[i],C[i]));
             ^
advisor.cpp:27:14: error: reference to 'next' is ambiguous
   pq.push(Pi(next[i],C[i]));
              ^~~~
advisor.cpp:10:5: note: candidates are: int next [100010]
 int next[100010],now[100010];
     ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/deque:60,
                 from /usr/include/c++/7/queue:60,
                 from advisor.cpp:2:
/usr/include/c++/7/bits/stl_iterator_base_funcs.h:208:5: note:                 template<class _ForwardIterator> _ForwardIterator std::next(_ForwardIterator, typename std::iterator_traits<_Iter>::difference_type)
     next(_ForwardIterator __x, typename
     ^~~~