답안 #18767

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

using namespace std;

int ans[100010];
bool check[100010];
#define pp pair<int,int>
priority_queue<pp> q;
int next[100010];
vector<int> paint[100010];
void ComputeAdvice(int *C, int N, int K, int M) {
    int i,j;
    int t,cnt;
    pp top;

	for(i=N; i>=1; i--) C[i] = C[i-1];
    t = 2; cnt = 1;
    while(true){
        if(t-1 >= N-1) break;
        cnt++;
        t *= 2;
    }
    for(i=1; i<=N; i++){
        if(check[C[i]] == false && C[i] < K){
            check[C[i]] = true;
            q.push(make_pair(i,C[i]));
        }
        paint[C[i]].push_back(i);
    }
    for(i=0; i<K; i++){
        if(check[i]) continue;
        check[i] = true;
        q.push(make_pair(999999999,i));
    }
    for(i=0; i<N; i++){
        t = paint[i].size();
        for(j=0; j<t-1; j++){
            next[paint[i][j]] = paint[i][j+1];
        }
        if(t != 0){
            next[paint[i][t-1]] = 999999999;
        }
    }
    for(i=1; i<=N; i++){
        t = C[i];
        if(check[t]){
			ans[i] = N;
			continue;
        }
        top = q.top();
        q.pop();
        ans[i] = top.second;
        check[top.second] = false;
        check[t] = true;
        q.push(make_pair(next[i],t));
    }
    for(i=1; i<=N; i++){
		if(ans[i] == N) WriteAdvice(0);
		else WriteAdvice(1);
    }
    for(i=1; i<=N; i++){
		if(ans[i] == N) continue;
		t = ans[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];
int change[100010];

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

	for(i=R; i>=1; i--) A[i] = A[i-1];
    t = 2; cnt = 1;
    while(true){
        if(t-1 >= N-1) break;
        cnt++;
        t *= 2;
    }
	for(i=1; i<=N; i++){
		change[i] = A[i];
	}
	rear = N;
	for(i=1; i<=N; i++){
		a[i] = GetRequest();
		if(change[i] == 0) continue;
		t = 1; sum = 0;
		for(j=rear+1; j<=rear+cnt; j++){
			sum += (t*A[j]);
			t *= 2;
		}
		PutBack(sum);
		rear += cnt;
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:42:13: error: reference to 'next' is ambiguous
             next[paint[i][j]] = paint[i][j+1];
             ^~~~
advisor.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 advisor.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
     ^~~~
advisor.cpp:45:13: error: reference to 'next' is ambiguous
             next[paint[i][t-1]] = 999999999;
             ^~~~
advisor.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 advisor.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
     ^~~~
advisor.cpp:59:26: error: reference to 'next' is ambiguous
         q.push(make_pair(next[i],t));
                          ^~~~
advisor.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 advisor.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
     ^~~~