답안 #18774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18774 2016-02-15T05:17:40 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],tc[100010];
bool check[100010];
#define pp pair<int,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=0; i<N; i++) tc[i] = C[i];
	for(i=N; i>=1; i--) C[i] = C[i-1];
    t = 2; cnt = 1;
    while(true){
        if(t-1 >= K-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,make_pair(C[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,make_pair(i,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.second;
        check[ans[i]] = false;
        check[t] = true;
        q.push(make_pair(next[i],make_pair(t,top.second.second)));
    }
    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;
		}
    }
    for(i=0; i<N; i++) C[i] = tc[i];
}
#include "assistant.h"
#include <stdio.h>
#include <queue>
#include <vector>
#include <stdlib.h>

using namespace std;

int a[100010];
int change[100010];
int bucket[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 >= K-1) break;
        cnt++;
        t *= 2;
    }
	for(i=1; i<=N; i++){
		change[i] = A[i];
	}
	rear = N;
	for(i=0; i<K; i++) bucket[i] = i;
	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(bucket[sum]);
		bucket[sum] = a[i];
		rear += cnt;
	}
}

Compilation message

advisor.cpp: In function 'void ComputeAdvice(int*, int, int, int)':
advisor.cpp:43: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:46: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:60:26: error: reference to 'next' is ambiguous
         q.push(make_pair(next[i],make_pair(t,top.second.second)));
                          ^~~~
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
     ^~~~