답안 #207052

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
207052 2020-03-06T08:57:26 Z Pentagon 주유소 (KOI16_gas) C++14
컴파일 오류
0 ms 0 KB
=#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue> 
using namespace std;
//Real Problem
int n,m,prc[2600],a,b,w;
long long DT[2600];
vector<int> arr;
bool cmp(int a,int b){
	if(prc[a]==prc[b])
		return a<b;
	return prc[a]<prc[b];
}
//for Dijkstra
int dis[2600][2600],INF=1e9;
struct node{
	int num,d;
	bool operator <(const node& tmp) const{
		return d>tmp.d;
	}
};
vector<vector<node> > v;
priority_queue<node> pq;
void Dijkstra(int s,int D[]){
	fill(D+1,D+n+1,INF);
	D[s]=0; pq.push(node{s,0});
	while(!pq.empty()){
		auto cur=pq.top(); pq.pop();
		if(cur.d>D[cur.num]) continue;
		for(auto&next : v[cur.num]){
			if(cur.d+next.d>=D[next.num]) continue;
			D[next.num]=D[cur.num]+next.d;
			pq.push(node{next.num,D[next.num]});
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) arr.push_back(i),scanf("%d",prc+i);
	v.resize(n+1);
	while(m--){
		scanf("%d%d%d",&a,&b,&w);
		v[a].push_back(node{b,w});
		v[b].push_back(node{a,w});
	}
	for(int i=1;i<=n;i++) Dijkstra(i,dis[i]);
	sort(arr.begin(),arr.end(),cmp);
	for(int i=0;i<n;i++){
		int k=arr[i];
		DT[k]=1LL*dis[k][n]*prc[k];
		for(int j=0;j<i;j++){
			int k2=arr[j];
			DT[k]=min(DT[k],1LL*dis[k][k2]*prc[k]+DT[k2]);
		}
		if(arr[i]==1) break;
	}
	printf("%lld",DT[1]);
}

Compilation message

gas.cpp:1:2: error: stray '#' in program
 =#include<stdio.h>
  ^
gas.cpp:1:1: error: expected unqualified-id before '=' token
 =#include<stdio.h>
 ^
In file included from /usr/include/c++/7/bits/stl_algobase.h:62:0,
                 from /usr/include/c++/7/vector:60,
                 from gas.cpp:2:
/usr/include/c++/7/ext/type_traits.h:162:35: error: 'bool __gnu_cxx::__is_null_pointer' redeclared as different kind of symbol
   __is_null_pointer(std::nullptr_t)
                                   ^
/usr/include/c++/7/ext/type_traits.h:157:5: note: previous declaration 'template<class _Type> bool __gnu_cxx::__is_null_pointer(_Type)'
     __is_null_pointer(_Type)
     ^~~~~~~~~~~~~~~~~
/usr/include/c++/7/ext/type_traits.h:162:26: error: 'nullptr_t' is not a member of 'std'
   __is_null_pointer(std::nullptr_t)
                          ^~~~~~~~~
In file included from /usr/include/c++/7/bits/move.h:54:0,
                 from /usr/include/c++/7/bits/stl_pair.h:59,
                 from /usr/include/c++/7/bits/stl_algobase.h:64,
                 from /usr/include/c++/7/vector:60,
                 from gas.cpp:2:
/usr/include/c++/7/type_traits:362:31: error: 'std::size_t' has not been declared
   template<typename _Tp, std::size_t _Size>
                               ^~~~~~
/usr/include/c++/7/type_traits:363:25: error: '_Size' was not declared in this scope
     struct is_array<_Tp[_Size]>
                         ^~~~~
/usr/include/c++/7/type_traits:363:31: error: template argument 1 is invalid
     struct is_array<_Tp[_Size]>
                               ^
/usr/include/c++/7/type_traits:561:42: error: 'nullptr_t' is not a member of 'std'
     struct __is_null_pointer_helper<std::nullptr_t>
                                          ^~~~~~~~~
/usr/include/c++/7/type_traits:561:42: error: 'nullptr_t' is not a member of 'std'
/usr/include/c++/7/type_traits:561:51: error: template argument 1 is invalid
     struct __is_null_pointer_helper<std::nullptr_t>
                                                   ^
/usr/include/c++/7/type_traits:1464:37: error: 'size_t' is not a member of 'std'
     : public integral_constant<std::size_t, __alignof__(_Tp)> { };
                                     ^~~~~~
/usr/include/c++/7/type_traits:1464:37: error: 'size_t' is not a member of 'std'
/usr/include/c++/7/type_traits:1464:61: error: template argument 1 is invalid
     : public integral_constant<std::size_t, __alignof__(_Tp)> { };
                                                             ^
/usr/include/c++/7/type_traits:1464:61: note: invalid template non-type parameter
/usr/include/c++/7/type_traits:1469:37: error: 'size_t' is not a member of 'std'
     : public integral_constant<std::size_t, 0> { };
                                     ^~~~~~
/usr/include/c++/7/type_traits:1469:37: error: 'size_t' is not a member of 'std'
/usr/include/c++/7/type_traits:1469:46: error: template argument 1 is invalid
     : public integral_constant<std::size_t, 0> { };
                                              ^
/usr/include/c++/7/type_traits:1469:46: note: invalid template non-type parameter
/usr/include/c++/7/type_traits:1471:31: error: 'std::size_t' has not been declared
   template<typename _Tp, std::size_t _Size>
                               ^~~~~~
/usr/include/c++/7/type_traits:1472:21: error: '_Size' was not declared in this scope
     struct rank<_Tp[_Size]>
                     ^~~~~
/usr/include/c++/7/type_traits:1472:27: error: template argument 1 is invalid
     struct rank<_Tp[_Size]>
                           ^
/usr/include/c++/7/type_traits:1473:37: error: 'size_t' is not a member of 'std'
     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
                                     ^~~~~~
/usr/include/c++/7/type_traits:1473:37: error: 'size_t' is not a member of 'std'
/usr/include/c++/7/type_traits:1473:65: error: template argument 1 is invalid
     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
                                                                 ^
/usr/include/c++/7/type_traits:1473:65: note: invalid template non-type parameter
/usr/include/c++/7/type_traits:1477:37: error: 'size_t' is not a member of 'std'
     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
                                     ^~~~~~
/usr/include/c++/7/type_traits:1477:37: error: 'size_t' is not a member of 'std'
/usr/include/c++/7/type_traits:1477:65: error: template argument 1 is invalid
     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
                                                                 ^
/usr/include/c++/7/type_traits:1477:65: note: invalid template non-type parameter
/usr/include/c++/7/type_traits:1482:37: error: 'size_t' is not a member of 'std'
     : public integral_constant<std::size_t, 0> { };
                                     ^~~~~~
/usr/include/c++/7/type_traits:1482:37: error: 'size_t' is not a member of 'std'
/usr/include/c++/7/type_traits:1482:46: error: template argument 1 is invalid
     : public integral_constant<std::size_t, 0> { };
                                              ^
/usr/include/c++/7/type_traits:1482:46: note: invalid template non-type parameter
/usr/include/c++/7/type_traits:1484:47: error: 'std::size_t' has not been declared
   template<typename _Tp, unsigned _Uint, std::size_t _Size>
                                               ^~~~~~
/usr/include/c++/7/type_traits:1485:23: error: '_Size' was not declared in this scope
     struct extent<_Tp[_Size], _Uint>
                       ^~~~~
/usr/include/c++/7/type_traits:1485:36: error: template argument 1 is invalid
     struct extent<_Tp[_Size], _Uint>
                                    ^
/usr/include/c++/7/type_traits:1486:37: error: 'size_t' is not a member of 'std'
     : public integral_constant<std::size_t,
                                     ^~~~~~
/usr/include/c++/7/type_traits:1486:37: error: 'size_t' is not a member of 'std'
/usr/include/c++/7/type_traits:1487:24: error: '_Size' was not declared in this scope
           _Uint == 0 ? _Size : extent<_Tp,
                        ^~~~~
/usr/include/c++/7/type_traits:1488:28: error: template argument 1 is invalid
           _Uint - 1>::value>
                            ^
/usr/include/c++/7/type_traits:1488:28: note: invalid template non-type parameter
/usr/include/c++/7/type_traits:1493:37: error: 'size_t' is not a member of 'std'
     : public integral_constant<std::size_t,
                                     ^~~~~~
/usr/include/c++/7/type_traits:1493:37: error: 'size_t' is not a member of 'std'
/usr/include/c++/7/type_traits:1495:31: error: template argument 1 is invalid
              _Uint - 1>::value>
                               ^
/usr/include/c++/7/type_traits:1495:31: note: invalid template non-type parameter
/usr/include/c++/7/type_traits:1944:31: error: 'std::size_t' has not been declared
   template<typename _Tp, std::size_t _Size>
                               ^~~~~~
/usr/include/c++/7/type_traits:1945:30: error: '_Size' was not declared in this scope
     struct remove_extent<_Tp[_Size]>
                              ^~~~~
/usr/include/c++/7/type_traits:1945:36: error: template argument 1 is invalid
     struct remove_extent<_Tp[_Size]>
                                    ^
/usr/include/c++/7/type_traits:1957:31: error: 'std::size_t' has not been declared
   template<typename _Tp, std::size_t _Size>
                               ^~~~~~
/usr/include/c++/7/type_traits:1958:35: error: '_Size' was not declared in this scope
     struct remove_all_extents<_Tp[_Size]>
                                   ^~~~~
/usr/include/c++/7/type_traits:1958:41: error: template argument 1 is invalid
     struct remove_all_extents<_Tp[_Size]>
                                         ^
/usr/include/c++/7/type_traits:2016:17: error: 'std::size_t' has not been declared
   template<std::size_t _Len>
                 ^~~~~~
/usr/include/c++/7/type_traits:2021:23: error: '_Len' was not declared in this scope
  unsigned char __data[_Len];
                       ^~~~
/usr/include/c++/7/type_traits:2036:17: error: 'std::size_t' has not been declared
   template<std::size_t _Len, std::size_t _Align =
                 ^~~~~~
/usr/include/c++/7/type_traits:2036:35: error: 'std::size_t' has not been declared
   template<std::size_t _Len, std::size_t _Align =
                                   ^~~~~~
/usr/include/c++/7/type_traits:2037:48: error: '_Len' was not declared in this scope
     __alignof__(typename __aligned_storage_msa<_Len>::__type)>
                                                ^~~~
/usr/include/c++/7/type_traits:2037:52: error: template argument 1 is invalid
     __alignof__(typename __aligned_storage_msa<_Len>::__type)>
                                                    ^
/usr/include/c++/7/type_traits:2042:23: error: '_Len' was not declared in this scope
  unsigned char __data[_Len];
                       ^~~~
/usr/include/c++/7/type_traits:2043:37: error: '_Align' was not declared in this scope
  struct __attribute__((__aligned__((_Align)))) { } __align;
                                     ^~~~~~
/usr/include/c++/7/type_traits:2050:20: error: 'size_t' does not name a type; did you mean '__size_t'?
       static const size_t _S_alignment = 0;
                    ^~~~~~
                    __size_t
/usr/include/c++/7/type_traits:2051:20: error: 'size_t' does not name a type; did you mean '__size_t'?
       static const size_t _S_size = 0;
                    ^~~~~~
                    __size_t
/usr/include/c++/7/type_traits:2057:20: error: 'size_t' does not name a type; did you mean '__size_t'?
       static const size_t _S_alignment =
                    ^~~~~~
                    __size_t
/usr/include/c++/7/type_traits:2060:20: error: 'size_t' does not name a type; did you mean '__size_t'?
       static const size_t _S_size =
                    ^~~~~~
                    __size_t
/usr/include/c++/7/type_traits:2075:13: error: 'size_t' has not been declared
   template <size_t _Len, typename... _Types>
             ^~~~~~
/usr/include/c++/7/type_traits:2082:20: error: 'size_t' does not name a type; did you mean '__size_t'?
       static const size_t _S_len = _Len > __strictest::_S_size
                    ^~~~~~
                    __size_t
/usr/include/c++/7/type_traits:2086:20: error: 'size_t' does not name a type; did you mean '__size_t'?
       static const size_t alignment_value = __strictest::_S_alignment;
                    ^~~~~~
                    __size_t
/usr/include/c++/7/type_traits:2088:40: error: '_S_len' was not declared in this scope
       typedef typename aligned_storage<_S_len, alignment_value>::type type;
                                        ^~~~~~
/usr/include/c++/7/type_traits:2088:48: error: 'alignment_value' was not declared in this scope
       typedef typename aligned_storage<_S_len, alignment_value>::type type;
                                                ^~~~~~~~~~~~~~~
/usr/include/c++/7/type_traits:2088:48: note: suggested alternative: 'alignment_of'
       typedef typename aligned_storage<_S_len, alignment_value>::type type;
                                                ^~~~~~~~~~~~~~~
                                                alignment_of
/usr/include/c++/7/type_traits:2088:63: error: template argument 1 is invalid
       typedef typename aligned_storage<_S_len, alignment_value>::type type;
                                                               ^
/usr/include/c++/7/type_traits:2088:63: error: template argument 2 is invalid
/usr/include/c++/7/type_traits:2091:13: error: 'size_t' has not been declared
   template <size_t _Len, typename... _Types>
             ^~~~~~
/usr/include/c++/7/type_traits:2092:11: error: 'size_t' does not name a type; did you mean '__size_t'?
     const size_t aligned_union<_Len, _Types...>::alignment_value;
           ^~~~~~
           __size_t
/usr/include/c++/7/type_traits:2463:12: error: 'size_t' has not been declared
   template<size_t _Len, size_t _Align =
            ^~~~~~
/usr/include/c++/7/type_traits:2463:25: error: 'size_t' has not been declared
   template<size_t _Len, size_t _Align =
                         ^~~~~~
/usr/include/c++/7/type_traits:2464:49: error: '_Len' was not declared in this scope
      __alignof__(typename __aligned_storage_msa<_Len>::__type)>
                                                 ^~~~
/usr/include/c++/7/type_traits:2464:53: error: template argument 1 is invalid
      __alignof__(typename __aligned_storage_msa<_Len>::__type)>
                                                     ^
/usr/include/c++/7/type_traits:2465:56: error: '_Len' was not declared in this scope
     using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
                                                        ^~~~
/usr/include/c++/7/type_traits:2465:62: error: '_Align' was not declared in this scope
     using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
                                                              ^~~~~~
/usr/include/c++/7/type_traits:2465:68: error: template argument 1 is invalid
     using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
                                                                    ^
/usr/include/c++/7/type_traits:2465:68: error: template argument 2 is invalid
/usr/include/c++/7/type_traits:2467:13: error: 'size_t' has not been declared
   template <size_t _Len, typename... _Types>
             ^~~~~~
/usr/include/c++/7/type_traits:2468:52: error: '_Len' was not declared in this scope
     using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
                                                    ^~~~
/usr/include/c++/7/type_traits:2468:67: error: template argument 1 is invalid
     using aligned_union_t = typename aligned_union<_Len, _Types...>::type;
                                                                   ^
/usr/include/c++/7/type_traits:2581:26: error: 'size_t' has not been declared
   template<typename _Tp, size_t _Nm>
                          ^~~~~~
/usr/include/c++/7/type_traits:2584:21: error: '_Nm' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                     ^~~
/usr/include/c++/7/type_traits:2584:24: error: 'template<class _Tp, <declaration error> > typename std::enable_if<std::__is_swappable<_Tp>::value>::type std::swap' conflicts with a previous declaration
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                        ^
/usr/include/c++/7/type_traits:2577:5: note: previous declaration 'typename std::enable_if<std::__and_<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type std::swap(_Tp&, _Tp&)'
     swap(_Tp&, _Tp&)
     ^~~~
/usr/include/c++/7/type_traits:2584:16: error: '__a' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                ^~~
/usr/include/c++/7/type_traits:2584:16: note: suggested alternative: '__N'
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                ^~~
                __N
/usr/include/c++/7/type_traits:2584:21: error: '_Nm' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                     ^~~
/usr/include/c++/7/type_traits:2584:33: error: '__b' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                                 ^~~
/usr/include/c++/7/type_traits:2584:33: note: suggested alternative: '__N'
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                                 ^~~
                                 __N
/usr/include/c++/7/type_traits:2584:38: error: '_Nm' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                                      ^~~
/usr/include/c++/7/type_traits:2585:5: error: expected ';' before 'noexcept'
     noexcept(__is_nothrow_swappable<_Tp>::value);
     ^~~~~~~~
In file included from /usr/include/c++/7/bits/stl_pair.h:59:0,
                 from /usr/include/c++/7/bits/stl_algobase.h:64,
                 from /usr/include/c++/7/vector:60,
                 from gas.cpp:2:
/usr/include/c++/7/bits/move.h:206:26: error: 'size_t' has not been declared
   template<typename _Tp, size_t _Nm>
                          ^~~~~~
/usr/include/c++/7/bits/move.h:210:21: error: '_Nm' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                     ^~~
/usr/include/c++/7/bits/move.h:210:24: error: 'template<class _Tp, <declaration error> > typename std::enable_if<std::__is_swappable<_Tp>::value>::type std::swap' conflicts with a previous declaration
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                        ^
/usr/include/c++/7/bits/move.h:187:5: note: previous declaration 'typename std::enable_if<std::__and_<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type std::swap(_Tp&, _Tp&)'
     swap(_Tp& __a, _Tp& __b)
     ^~~~
/usr/include/c++/7/bits/move.h:210:16: error: '__a' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                ^~~
/usr/include/c++/7/bits/move.h:210:16: note: suggested alternative: '__N'
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                ^~~
                __N
/usr/include/c++/7/bits/move.h:210:21: error: '_Nm' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                     ^~~
/usr/include/c++/7/bits/move.h:210:33: error: '__b' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                                 ^~~
/usr/include/c++/7/bits/move.h:210:33: note: suggested alternative: '__N'
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                                 ^~~
                                 __N
/usr/include/c++/7/bits/move.h:210:38: error: '_Nm' was not declared in this scope
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
                                      ^~~
/usr/include/c++/7/bits/move.h:211:5: error: expected ';' before 'noexcept'
     noexcept(__is_nothrow_swappable<_Tp>::value)
     ^~~~~~~~
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/7/vector:60,
                 from gas.cpp:2:
/usr/include/c++/7/bits/stl_pair.h:86:17: error: 'std::size_t' has not been declared
   template<std::size_t...>
                 ^~~~~~
/usr/include/c++/7/bits/stl_pair.h:429:41: error: 'std::size_t' has not been declared
       template<typename... _Args1, std::size_t... _Indexes1,
                                         ^~~~~~
/usr/include/c++/7/bits/stl_pair.h:430:41: error: 'std::size_t' has not been declared
                typename... _Args2, std::size_t... _Indexes2>
                                         ^~~~~~
/usr/include/c++/7/bits/stl_pair.h:432:27: error: '_Indexes1' was not declared in this scope
              _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
                           ^~~~~~~~~
/usr/include/c++/7/bits/stl_pair.h:432:27: note: suggested alternative: '_Index_tuple'
              _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
                           ^~~~~~~~~
                           _Index_tuple
/usr/include/c++/7/bits/stl_pair.h:432:36: error: expected parameter pack before '...'
              _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
                                    ^~~
/usr/include/c++/7/bits/stl_pair.h:432:39: error: template argument 1 is invalid
              _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>);
                                       ^
/usr/include/c++/7/bits/stl_pair.h:432:55: error: '_Indexes2' was not declared in this scope
              _Index_tuple<_Indexes1...>, _Ind