답안 #750888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750888 2023-05-30T12:40:43 Z blgutei000 사이버랜드 (APIO23_cyberland) C++17
컴파일 오류
0 ms 0 KB
#include "cyberland.h"
#include<bits/stdc++.h>
#include <vector>

#define ll long long
#define pi std::pair<ll , ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()

const ll N = 1e18;
const int maxn = 1e5 + 1;

std::vector<pi> adj[maxn];
std::vector<int> cost;
int dist[maxn] , arr[maxn];
bool vis[maxn] , vis1[maxn];
std::set<pi> s;
std::set<pi> :: iterator it;
void dfs(int a) {
	vis[a] = true;
	for(int i = 0; i < adj[a].sz; i++) {
		int b = adj[a][i].ff;
		if(arr[b] == 0) cost.pb(b);
		if(!vis[b]) dfs(b);
	}
}
double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
	for(int i = 0; i < m; i++) {
		adj[x[i]].pb(mp(y[i] , c[i]));
		adj[y[i]].pb(mp(x[i] , c[i]));
	}
	for(int i = 0; i < n; i++) {
		dist[i] = N;
	}
	dfs(0);
	dist[h - 1] = 0;
	s.insert(0 , h - 1);
	while(!s.empty()) {
		it = s.begin();
		int u = it -> ss;
		s.erase(it);
		if(vis1[u]) continue;
		vis1[u] = true;
		for(int i = 0; i < adj[u].sz; i++) {
			int v = adj[u][i].ff;
			int w = adj[u][i].ss;
			if(dist[u] + w < dist[v]) {
				dist[v] = dist[u] + w;
				s.insert(mp(dist[v] , v));
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i < cost.sz i++) {
		if(ans < dist[cost[i]]) ans = dist[cost[i]];
	}
	std::cout << ans << std::endl;
    return -1;
}

Compilation message

cyberland.cpp: In function 'void dfs(int)':
cyberland.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i = 0; i < adj[a].sz; i++) {
      |                   ^
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:8:12: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
    8 | #define mp make_pair
      |            ^~~~~~~~~
cyberland.cpp:32:16: note: in expansion of macro 'mp'
   32 |   adj[x[i]].pb(mp(y[i] , c[i]));
      |                ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: 'std::make_pair' declared here
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
cyberland.cpp:36:13: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   36 |   dist[i] = N;
      |             ^
cyberland.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(int i = 0; i < adj[u].sz; i++) {
      |                    ^
cyberland.cpp:8:12: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
    8 | #define mp make_pair
      |            ^~~~~~~~~
cyberland.cpp:52:14: note: in expansion of macro 'mp'
   52 |     s.insert(mp(dist[v] , v));
      |              ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: 'std::make_pair' declared here
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
cyberland.cpp:57:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i = 0; i < cost.sz i++) {
      |                   ^
cyberland.cpp:57:29: error: expected ';' before 'i'
   57 |  for(int i = 0; i < cost.sz i++) {
      |                             ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_set.h: In instantiation of 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]':
cyberland.cpp:40:20:   required from here
/usr/include/c++/10/bits/stl_set.h:567:31: error: no matching function for call to 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_insert_range_unique(int&, int&)'
  567 |  { _M_t._M_insert_range_unique(__first, __last); }
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from cyberland.cpp:2:
/usr/include/c++/10/bits/stl_tree.h:1105:2: note: candidate: 'template<class _InputIterator> std::__enable_if_t<std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
 1105 |  _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h:1105:2: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<std::is_same<std::pair<long long int, long long int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value, void> std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_insert_range_unique<_InputIterator>(_InputIterator, _InputIterator) [with _InputIterator = int]':
/usr/include/c++/10/bits/stl_set.h:567:31:   required from 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
cyberland.cpp:40:20:   required from here
/usr/include/c++/10/bits/stl_tree.h:1105:2: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
/usr/include/c++/10/bits/stl_set.h: In instantiation of 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]':
cyberland.cpp:40:20:   required from here
/usr/include/c++/10/bits/stl_tree.h:1114:2: note: candidate: 'template<class _InputIterator> std::__enable_if_t<(! std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value)> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
 1114 |  _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h:1114:2: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<(! std::is_same<std::pair<long long int, long long int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value), void> std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_M_insert_range_unique<_InputIterator>(_InputIterator, _InputIterator) [with _InputIterator = int]':
/usr/include/c++/10/bits/stl_set.h:567:31:   required from 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >]'
cyberland.cpp:40:20:   required from here
/usr/include/c++/10/bits/stl_tree.h:1113:52: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
 1113 |  __enable_if_t<!__same_value_type<_InputIterator>::value>
      |                                                    ^~~~~