Submission #19024

# Submission time Handle Problem Language Result Execution time Memory
19024 2016-02-17T05:42:27 Z suhgyuho_william Rail (IOI14_rail) C++
Compilation error
0 ms 0 KB
#include "rail.h"
#include <algorithm>
#include <stdio.h>

using namespace std;

int dis0[5010];
int disx[5010];
int bef[5010],next[5010];
int op[5010],num[5010];
bool cmp(int x,int y){
	return dis0[x] < dis0[y];
}
bool cmp2(int x,int y){
	return disx[x] < disx[y];
}

void findLocation(int N, int first, int location[], int stype[]){
	int i,j;
	int small,x;
	int t,v,nv;
	int rear,tmp;

	location[0] = first; stype[0] = 1;
	small = 999999999;
    for(i=1; i<N; i++){
		dis0[i] = getDistance(0,i);
		if(small > dis0[i]){
			small = dis0[i];
			x = i;
		}
    }
    location[x] = first+dis0[x];
    stype[x] = 2;
	for(i=1; i<N; i++){
		if(i == x) continue;
		disx[i] = getDistance(x,i);
		if(dis0[i] == dis0[x]+disx[i]) op[i] = 2;
		else op[i] = 1;
	}
	rear = 0;
	for(i=1; i<N; i++){
		if(op[i] == 1){
			rear++;
			num[rear] = i;
		}
	}
	sort(num+1,num+rear+1,cmp);
	tmp = 0;
	for(i=1; i<=rear; i++){
		v = num[i];
		t = getDistance(v,0);
		if(dis0[v] == t){
			location[v] = first+dis0[v];
			stype[v] = 2;
			bef[v] = tmp;
			tmp = v;
		}else{
			for(j=1; j<i; j++){
				nv = num[j];
				if(stype[nv] == 1) continue;
				location[v] = location[nv]-(t-dis0[nv]);
				if(location[bef[nv]] < location[v] && location[v] < location[nv]) break;
			}
			if(j == i) while(true){}
			stype[v] = 1;
		}
	}
	rear = 0;
	for(i=1; i<N; i++){
		if(op[i] == 2){
			rear++;
			num[rear] = i;
		}
	}
	sort(num+1,num+rear+1,cmp2);
	tmp = N; location[N] = location[x];
	for(i=1; i<=rear; i++){
		v = num[i];
		if(tmp == N){
			stype[v] = 1;
			location[v] = location[x]-(t-small);
			next[v] = tmp;
			tmp = v;
			continue;
		}
        t = getDistance(tmp,v);
        if(disx[v] == disx[tmp]+t){
			stype[v] = 2;
			for(j=1; j<i; j++){
				nv = num[j];
				if(stype[nv] == 2) continue;
				location[v] = location[nv]+disx[v]-disx[nv];
				//printf("%d\n",nv);
				if(location[nv] < location[v] && location[v] < location[next[nv]]) break;
			}
        }else{
        	stype[v] = 1;
        	location[v] = location[x]-disx[v];
        	next[v] = tmp;
        	tmp = v;
        }
	}
	/*for(i=0; i<N; i++){
		printf("%d %d\n",stype[i],location[i]);
	}*/
}

Compilation message

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:83:4: error: reference to 'next' is ambiguous
    next[v] = tmp;
    ^~~~
rail.cpp:9:15: note: candidates are: int next [5010]
 int bef[5010],next[5010];
               ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/algorithm:61,
                 from rail.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
     ^~~~
rail.cpp:95:61: error: reference to 'next' is ambiguous
     if(location[nv] < location[v] && location[v] < location[next[nv]]) break;
                                                             ^~~~
rail.cpp:9:15: note: candidates are: int next [5010]
 int bef[5010],next[5010];
               ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/algorithm:61,
                 from rail.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
     ^~~~
rail.cpp:100:10: error: reference to 'next' is ambiguous
          next[v] = tmp;
          ^~~~
rail.cpp:9:15: note: candidates are: int next [5010]
 int bef[5010],next[5010];
               ^~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:66:0,
                 from /usr/include/c++/7/algorithm:61,
                 from rail.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
     ^~~~