Submission #380785

#TimeUsernameProblemLanguageResultExecution timeMemory
380785evnTales of seafaring (POI13_mor)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define sz(a) a.size() typedef long long ll; typedef pair<int, int> pii; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int n, m, k; short dp[5005][5005][2]; vector<int> adj[5005]; bool vis[5005][2]; queue<pii> q; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> k; for(int i = 0; i < m;i ++){ int a, b; cin >> a >> b; a--; b--; adj[a].pb(b); adj[b].pb(a); } for(int i = 0; i < n;i ++){ for(int j = 0;j < n;j ++){ dp[i][j][0] = 5001; dp[i][j][1] = 5001; } } for(int i = 0;i < n; i++){ //launch a bfs from node i memset(vis, false, sizeof(vis)); vis[i][0] = true; q.push({i,0}); dp[i][i][0] = 0; while(!q.empty()){ pii c = q.front(); q.pop(); if(c.s != dp[i][c.f][c.s%2])continue; vis[c.f][c.s%2] = true; for(int u : adj[c.f]){ int pa = c.s%2; if(!vis[u][(pa+1)%2]){ dp[i][u][(pa+1)%2] = min(dp[i][u][(pa+1)%2],(short)c.s+1); q.push({u, (c.s+1)}); } } } } for(int i = 0; i < k;i ++){ int a, b, d; cin >> a >> b >> d; a--; b--; bool works = false; if(dp[a][b][d%2] <= d && dp[a][b][d%2] != 5001)works = true; cout << (works ? "TAK":"NIE") << '\n'; } }

Compilation message (stderr)

mor.cpp: In function 'int main()':
mor.cpp:50:62: error: no matching function for call to 'min(short int&, int)'
   50 |      dp[i][u][(pa+1)%2] = min(dp[i][u][(pa+1)%2],(short)c.s+1);
      |                                                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 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 mor.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
mor.cpp:50:62: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   50 |      dp[i][u][(pa+1)%2] = min(dp[i][u][(pa+1)%2],(short)c.s+1);
      |                                                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 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 mor.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
mor.cpp:50:62: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   50 |      dp[i][u][(pa+1)%2] = min(dp[i][u][(pa+1)%2],(short)c.s+1);
      |                                                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from mor.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
mor.cpp:50:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   50 |      dp[i][u][(pa+1)%2] = min(dp[i][u][(pa+1)%2],(short)c.s+1);
      |                                                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from mor.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
mor.cpp:50:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   50 |      dp[i][u][(pa+1)%2] = min(dp[i][u][(pa+1)%2],(short)c.s+1);
      |                                                              ^