Submission #667794

#TimeUsernameProblemLanguageResultExecution timeMemory
667794Kaztaev_AlisherEvacuation plan (IZhO18_plan)C++17
Compilation error
0 ms0 KiB
//#pragma GCC optomize ("Ofast") //#pragma GCC optomize ("unroll-loops") //#pragma GCC target ("avx,avx2,fma") #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define sz size #define cl clear #define ins insert #define ers erase #define pii pair < int , int > #define pll pair< long long , long long > #define all(x) x.begin() , x.end() #define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) #define tostr(x) to_string(x) #define tonum(s) atoi(s.c_str()) #define seon(x) setprecision(x) #define bpop(x) __builtin_popcount(x) #define deb(x) cerr << #x << " = " << x << endl; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; const double PI = 3.14159265; const ll N = 20; const ll mod = 1e9+7; const ll inf = 1e9; const ll INF = 1e18; using namespace std; ll n , m , q; ll dp[N]; vector<pll> g[N]; void bfs(){ set<pll> st; int k; cin >> k; for(int i = 1; i <= n; i++) dp[i] = inf; for(int i = 1; i <= k; i++) { int u; cin >> u; dp[u] = 0; st.ins({0 , u}); } while(st.sz()){ int v = st.begin()->S; st.ers(st.begin()); for(pii to : g[v]){ if(dp[to.F] > dp[v]+to.S){ st.ers({dp[to.F] , to.F}); dp[to.F] = dp[v]+to.S; st.ins({dp[to.F] , to.F}); } } } } pll road[N][N]; void solve(){ cin >> n >> m; for(int i = 1; i <= m; i++){ int a, b , c; cin >> a>> b >> c; g[a].pb({b , c}); g[b].pb({a , c}); } bfs(); for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ road[i][j] = {inf , dp[to.F]}; } } for(int i = 1; i <= n; i++){ road[i][i] = {0 , dp[i]}; set<pair<pii , int > > st; st.ins({road[i][i] , i}); while(st.sz()){ pair<pll , ll > v = *st.begin(); st.ers(st.begin()); for(pair<int , int> to : g[v.S]){ if(road[i][to.F].F > road[i][v.S].F + to.S){ st.ers({road[i][to.F] , to.F}); road[i][to.F] = road[i][v.S]; road[i][to.F].F += to.S; road[i][to.F].S = min(road[i][to.F].S , dp[to.F]); st.ins({road[i][to.F] , to.F}); } else if(road[i][to.F].F == road[i][v.S].F + to.S){ if(road[i][to.F].S < min(road[i][v.S].S , dp[to.F])){ st.ers({road[i][to.F] , to.F}); road[i][to.F] = road[i][v.S]; road[i][to.F].S = min(road[i][to.F].S , dp[to.F]); st.ins({road[i][to.F] , to.F}); } } } } } cin >> q; while(q--){ int u , v; cin >> u >> v; cout << min(road[v][u].S , road[u][v].S) <<"\n"; } } signed main(){ ios; solve(); return 0; } /* */

Compilation message (stderr)

plan.cpp: In function 'void solve()':
plan.cpp:76:27: error: 'to' was not declared in this scope; did you mean 'tm'?
   76 |    road[i][j] = {inf , dp[to.F]};
      |                           ^~
      |                           tm
plan.cpp:76:32: error: no match for 'operator=' (operand types are 'std::pair<long long int, long long int>' and '<brace-enclosed initializer list>')
   76 |    road[i][j] = {inf , dp[to.F]};
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from plan.cpp:5:
/usr/include/c++/10/bits/stl_pair.h:390:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_copy_assignable<_T1>, std::is_copy_assignable<_T2> >::value, const std::pair<_T1, _T2>&, const std::__nonesuch&>::type = const std::pair<long long int, long long int>&]'
  390 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:393:41: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, const std::pair<long long int, long long int>&, const std::__nonesuch&>::type' {aka 'const std::pair<long long int, long long int>&'}
  390 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~    
  391 |   __and_<is_copy_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
  392 |          is_copy_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393 |   const pair&, const __nonesuch&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:401:7: note: candidate: 'std::pair<_T1, _T2>& std::pair<_T1, _T2>::operator=(typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type) [with _T1 = long long int; _T2 = long long int; typename std::conditional<std::__and_<std::is_move_assignable<_Tp>, std::is_move_assignable<_T2> >::value, std::pair<_T1, _T2>&&, std::__nonesuch&&>::type = std::pair<long long int, long long int>&&]'
  401 |       operator=(typename conditional<
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:404:31: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::conditional<true, std::pair<long long int, long long int>&&, std::__nonesuch&&>::type' {aka 'std::pair<long long int, long long int>&&'}
  401 |       operator=(typename conditional<
      |                 ~~~~~~~~~~~~~~~~~~~~~
  402 |   __and_<is_move_assignable<_T1>,
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  403 |          is_move_assignable<_T2>>::value,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  404 |   pair&&, __nonesuch&&>::type __p)
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, const _U1&>, std::is_assignable<_T2&, const _U2&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  418 |  operator=(const pair<_U1, _U2>& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:418:2: note:   template argument deduction/substitution failed:
plan.cpp:76:32: note:   couldn't deduce template parameter '_U1'
   76 |    road[i][j] = {inf , dp[to.F]};
      |                                ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from plan.cpp:5:
/usr/include/c++/10/bits/stl_pair.h:430:2: note: candidate: 'template<class _U1, class _U2> typename std::enable_if<std::__and_<std::is_assignable<_T1&, _U1&&>, std::is_assignable<_T2&, _U2&&> >::value, std::pair<_T1, _T2>&>::type std::pair<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U1 = _U1; _U2 = _U2; _T1 = long long int; _T2 = long long int]'
  430 |  operator=(pair<_U1, _U2>&& __p)
      |  ^~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:430:2: note:   template argument deduction/substitution failed:
plan.cpp:76:32: note:   couldn't deduce template parameter '_U1'
   76 |    road[i][j] = {inf , dp[to.F]};
      |                                ^