Submission #257468

# Submission time Handle Problem Language Result Execution time Memory
257468 2020-08-04T09:53:56 Z tinjyu Sky Walking (IOI19_walk) C++17
Compilation error
0 ms 0 KB
#include "walk.h"
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
struct node{
	long long int dis,id;
}t[10000005];
struct Node{
	long long int id,h;
}tmp[3000005];
long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
int connect(int a,int b,long long int len)
{
	//cout<<a<<" "<<b<<" "<<len<<endl;
	cont++;
	map[cont][0]=b;
	map[cont][1]=road[a];
	map[cont][2]=len;
	road[a]=cont;
	cont++;
	map[cont][0]=a;
	map[cont][1]=road[b];
	map[cont][2]=len;
	road[b]=cont;
	return 0;
}
struct cmp{
	bool operator()(const node &a,const node &b)
	{
		return a.dis>b.dis;
	}
};
int dijk()
{
	for(int i=1;i<=cnt;i++)dis[i]=100000000000000;
	dis[st]=0;
	t[1].id=st;
	t[1].dis=0;
	long long int pp=1;
	while(pp>=1)
	{
		pop_heap(t+1,t+pp+1,cmp());
		long long int x=t[pp].id,len=t[pp].dis;
		pp--;
		if(len!=dis[x])
		{
			continue;
		}
		//cout<<x<<" "<<len<<" "<<p[x]<<endl;
		long long int g=road[x];
		while(g!=-1){
			long long int now=map[g][0];
			//cout<<now<<" "<<dis[now]<<" "<<p[now]<<" "<<hp[now]<<endl;
			if(len+map[g][2]<dis[now]){
				dis[now]=len+map[g][2];
				pp++;
				t[pp].id=now;
				t[pp].dis=dis[now];
				push_heap(t+1,t+pp+1,cmp());
			}
			g=map[g][1];
		}
		//cout<<endl;
	}
	return 0;
}
bool cmp2(Node a,Node b)
{
	return a.h<b.h;
}
long long min_distance(std::vector<int> x, std::vector<int> h, std::vector<int> l, std::vector<int> r, std::vector<int> y, int s, int g) {
	n=x.size();
	m=l.size();
	for(int i=0;i<=min((long long int)10000000,n*m);i++)road[i]=-1;
	for(int i=0;i<n;i++)pointer[i]=-1;
	st=0;

	for(int i=0;i<m;i++){
		cnt++;
		num[l[i]]++;
		p[cnt]=l[i];
		hp[cnt]=y[i];
		cntp++;
		data[cntp][0]=cnt;
		data[cntp][1]=y[i];
		data[cntp][2]=pointer[l[i]];
		pointer[l[i]]=cntp;
		long long int pr=cnt,prex=x[l[i]];
		for(int j=l[i]+1;j<=r[i];j++){
			if(h[j]>=y[i])
			{
				cnt++;
				cntp++;
				data[cntp][0]=cnt;
				data[cntp][1]=y[i];
				data[cntp][2]=pointer[j];
				pointer[j]=cntp;
				connect(cnt,pr,x[j]-prex);
				pr=cnt;
				prex=x[j];
			}
		}
	}
	

	cnt++;
	st=cnt;
	cntp++;
	data[cntp][0]=cnt;
	data[cntp][1]=0;
	data[cntp][2]=pointer[s];
	pointer[s]=cntp;
	
	cnt++;
	cntp++;
	data[cntp][0]=cnt;
	data[cntp][1]=0;
	data[cntp][2]=pointer[g];
	pointer[g]=cntp;
	for(int i=0;i<n;i++)
	{
		long long int g=pointer[i],tmpcount=0;
		while(g!=-1)
		{
			tmpcount++;
			tmp[tmpcount].id=data[g][0];
			tmp[tmpcount].h=data[g][1];
			g=data[g][2];
		}
		sort(tmp+1,tmp+tmpcount+1,cmp2);
		//for(int j=1;j<=tmpcount;j++)cout<<tmp[j].id<<" "<<tmp[j].h<<"  ";
		//cout<<endl;
		for(int j=1;j<tmpcount;j++)
		{
			connect(tmp[j].id,tmp[j+1].id,tmp[j+1].h-tmp[j].h);

		}
		//cout<<endl;
	}
	dijk();
	if(dis[cnt]==100000000000000)return -1;
	return dis[cnt];
}

Compilation message

walk.cpp: In function 'long long int min_distance(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int, int)':
walk.cpp:85:3: error: reference to 'data' is ambiguous
   data[cntp][0]=cnt;
   ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:86:3: error: reference to 'data' is ambiguous
   data[cntp][1]=y[i];
   ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:87:3: error: reference to 'data' is ambiguous
   data[cntp][2]=pointer[l[i]];
   ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:95:5: error: reference to 'data' is ambiguous
     data[cntp][0]=cnt;
     ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:96:5: error: reference to 'data' is ambiguous
     data[cntp][1]=y[i];
     ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:97:5: error: reference to 'data' is ambiguous
     data[cntp][2]=pointer[j];
     ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:110:2: error: reference to 'data' is ambiguous
  data[cntp][0]=cnt;
  ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:111:2: error: reference to 'data' is ambiguous
  data[cntp][1]=0;
  ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:112:2: error: reference to 'data' is ambiguous
  data[cntp][2]=pointer[s];
  ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:117:2: error: reference to 'data' is ambiguous
  data[cntp][0]=cnt;
  ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:118:2: error: reference to 'data' is ambiguous
  data[cntp][1]=0;
  ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:119:2: error: reference to 'data' is ambiguous
  data[cntp][2]=pointer[g];
  ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
walk.cpp:127:21: error: reference to 'data' is ambiguous
    tmp[tmpcount].id=data[g][0];
                     ^~~~
walk.cpp:12:111: note: candidates are: long long int data [30000005][3]
 long long int p[10000005],hp[10000005],dis[10000005],m,n,road[10000005],map[30000005][3],cntp,pointer[100005],data[30000005][3],num[100005],cont,st,cnt;
                                                                                                               ^~~~
In file included from /usr/include/c++/7/vector:66:0,
                 from walk.h:4,
                 from walk.cpp:1:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container