제출 #339294

#제출 시각아이디문제언어결과실행 시간메모리
339294Dilshod_ImomovEvacuation plan (IZhO18_plan)C++17
컴파일 에러
0 ms0 KiB
# include <bits/stdc++.h> # define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) # define int long long # define fi first # define se second using namespace std; const int N = 2e6 + 7; const int mod = 1e9 + 7; vector < pair < int, int > > adj[N]; int dist[N], n, m, go, pr[N], ans[N], size[N]; bool used[N]; set < int > st[N]; int find_set( int a ) { if ( a == pr[a] ) { return a; } return find_set(pr[a]); } void merge( int a, int b, int val ) { int x = find_set(a); int y = find_set(b); if ( x == y ) { return; } if ( size[x] < size[y] ) { swap( x, y ); } for ( auto i: st[y] ) { if ( st[x].count(i) ) { ans[ i ] = val; } else { st[x].insert(i); } } st[y].clear(); pr[y] = x; size[x] += size[y]; } int32_t main() { speed; cin >> n >> m; for ( int i = 1; i <= m; i++ ) { int u, v, w; cin >> u >> v >> w; adj[u].push_back( { v, w } ); adj[v].push_back( { u, w } ); } for ( int i = 1; i <= n; i++ ) { dist[i] = 1e12; pr[i] = i; size[i] = 1; } int k; cin >> k; set < pair < int, int > > q; for ( int i = 1; i <= k; i++ ) { int x; cin >> x; q.insert( { 0, x } ); dist[x] = 0; } while ( !q.empty() ) { int v = q.begin()->se; q.erase( q.begin() ); for ( auto pr: adj[v] ) { int u = pr.fi, w = pr.se; if ( dist[u] > dist[v] + w ) { q.erase( { dist[u], u } ); dist[u] = dist[v] + w; q.insert( { dist[u], u } ); } } } int qr; cin >> qr; for ( int i = 1; i <= qr; i++ ) { int x, y; cin >> x >> y; st[x].insert(i); st[y].insert(i); } vector < pair < int, int > > vc; for ( int i = 1; i <= n; i++ ) { vc.push_back( { dist[i], i } ); } sort( vc.rbegin(), vc.rend() ); for ( int i = 0; i < n; i++ ) { int x = vc[i].se; used[x] = 1; // cout << x << endl; for ( auto pr: adj[x] ) { int u = pr.fi; if ( used[u] ) { merge( x, u, dist[x] ); } } } for ( int i = 1; i <= qr; i++ ) { cout << ans[i] << '\n'; } }

컴파일 시 표준 에러 (stderr) 메시지

plan.cpp: In function 'void merge(long long int, long long int, long long int)':
plan.cpp:30:10: error: reference to 'size' is ambiguous
   30 |     if ( size[x] < size[y] ) {
      |          ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plan.cpp:1:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
plan.cpp:13:39: note:                 'long long int size [2000007]'
   13 | int dist[N], n, m, go, pr[N], ans[N], size[N];
      |                                       ^~~~
plan.cpp:30:20: error: reference to 'size' is ambiguous
   30 |     if ( size[x] < size[y] ) {
      |                    ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plan.cpp:1:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
plan.cpp:13:39: note:                 'long long int size [2000007]'
   13 | int dist[N], n, m, go, pr[N], ans[N], size[N];
      |                                       ^~~~
plan.cpp:43:5: error: reference to 'size' is ambiguous
   43 |     size[x] += size[y];
      |     ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plan.cpp:1:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
plan.cpp:13:39: note:                 'long long int size [2000007]'
   13 | int dist[N], n, m, go, pr[N], ans[N], size[N];
      |                                       ^~~~
plan.cpp:43:16: error: reference to 'size' is ambiguous
   43 |     size[x] += size[y];
      |                ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plan.cpp:1:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
plan.cpp:13:39: note:                 'long long int size [2000007]'
   13 | int dist[N], n, m, go, pr[N], ans[N], size[N];
      |                                       ^~~~
plan.cpp: In function 'int32_t main()':
plan.cpp:58:9: error: reference to 'size' is ambiguous
   58 |         size[i] = 1;
      |         ^~~~
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from plan.cpp:1:
/usr/include/c++/9/bits/range_access.h:252:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  252 |     size(const _Tp (&/*__array*/)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/9/bits/range_access.h:242:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  242 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
plan.cpp:13:39: note:                 'long long int size [2000007]'
   13 | int dist[N], n, m, go, pr[N], ans[N], size[N];
      |                                       ^~~~