답안 #18742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18742 2016-02-15T03:52:11 Z suhgyuho_william 최후의 만찬 (IOI12_supper) C++
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#include "advisor.h"

void ComputeAdvice(int *C, int N, int K, int M) {
	int i,j;
	int t,cnt;

	t = cnt = 1;
	while(true){
		if(t >= N-1) break;
		cnt++;
		t *= 2;
	}
	for(i=0; i<N; i++){
		t = C[i];
		for(j=1; j<=cnt; j++){
			WriteAdvice(t%2);
			t /= 2;
		}
	}
}
#include "assistant.h"
#include <stdio.h>
#include <queue>
#include <vector>
#include <stdlib.h>

using namespace std;

int a[100010];
bool check[100010];
#define pp pair<int,int>
priority_queue<pp> q;
int next[100010];
vector<int> color[100010];

void Assist(unsigned char *A, int N, int K, int R) {
	int i,j;
	int t,cnt;
	pp top;

	t = cnt = 1;
	while(true){
		if(t >= N-1) break;
		cnt++;
		t *= 2;
	}
	for(i=0; i<N*cnt; i+=cnt){
		t = 1;
		for(j=0; j<cnt; j++){
			a[(i/cnt)+1] += (t*A[i+j]);
			t *= 2;
		}
	}
	for(i=1; i<=N; i++){
        if(check[a[i]] == false && a[i] < K){
			check[a[i]] = true;
			q.push(make_pair(i,a[i]));
        }
        color[a[i]].push_back(i);
	}
	for(i=0; i<K; i++){
		if(check[i]) continue;
		check[i] = true;
		q.push(make_pair(0,i));
	}
	for(i=0; i<N; i++){
		for(j=0; j<color[i].size()-1; j++){
			printf("%d %d\n",color[i][j],color[i][j+1]);
			next[color[i][j]] = color[i][j+1];
		}
		if(color[i].size() != 0){
			next[color[i][color[i].size()-1]] = 0;
		}
	}
	for(i=1; i<=N; i++){
		t = GetRequest();
		if(check[t]) continue;
		PutBack(t);
		top = q.top();
		q.pop();
		check[top.second] = false;
		check[t] = true;
		q.push(make_pair(next[i],t));
	}
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:47:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0; j<color[i].size()-1; j++){
            ~^~~~~~~~~~~~~~~~~~
assistant.cpp:49:4: error: reference to 'next' is ambiguous
    next[color[i][j]] = color[i][j+1];
    ^~~~
assistant.cpp:13:5: note: candidates are: int next [100010]
 int next[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 assistant.cpp:3:
/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
     ^~~~
assistant.cpp:52:4: error: reference to 'next' is ambiguous
    next[color[i][color[i].size()-1]] = 0;
    ^~~~
assistant.cpp:13:5: note: candidates are: int next [100010]
 int next[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 assistant.cpp:3:
/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
     ^~~~
assistant.cpp:63:20: error: reference to 'next' is ambiguous
   q.push(make_pair(next[i],t));
                    ^~~~
assistant.cpp:13:5: note: candidates are: int next [100010]
 int next[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 assistant.cpp:3:
/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
     ^~~~