Submission #635934

#TimeUsernameProblemLanguageResultExecution timeMemory
635934Cross_RatioToll (APIO13_toll)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> root; UnionFind(int N) { root.resize(N); fill(root.begin(),root.end(),-1); } int Find(int n) { if(root[n]<0) return n; int r = Find(root[n]); root[n] = r; return r; } void Merge(int x, int y) { x = Find(x), y = Find(y); if(x==y) return; root[x] = y; } }; typedef pair<long long int, long long int> P; long long int dis[30]; long long int D[25]; long long int dfs(int c, int p, vector<vector<int>> adj) { dis[c] = D[c]; for(int k : adj[c]) { if(k==p) continue; dis[c] += dfs(k, c, adj); } return dis[c]; } int A[25]; int B[25]; long long int C[25]; int S, E; int N, M; long long int get_ans(int c, int p) { vector<array<long long int, 3>> V; int i; for(i=0;i<M;i++) V.push_back({C[i], A[i], B[i]}); V.push_back({c, S, E}); sort(V.begin(),V.end()); UnionFind UF(N); vector<vector<int>> adj; adj.resize(N); for(i=0;i<V.size();i++) { auto it = V[i]; if(it[0]==c&&UF.Find(S)==UF.Find(E)) return 0; if(UF.Find(it[1])==UF.Find(it[2])) continue; UF.Merge(it[1], it[2]); adj[it[1]].push_back(it[2]); adj[it[2]].push_back(it[1], it[0]); } dfs(0, -1, adj); long long int ans = min(dis[S], dis[E]) * (c+p)/2; return ans; } signed main() { cin.sync_with_stdio(false); cin.tie(0); cout.tie(0); int K; cin >> N >> M >> K; int i, j; for(i=0;i<M;i++) { cin >> A[i] >> B[i] >> C[i]; A[i]--; B[i]--; C[i] *= 2; } cin >> S >> E; S--; E--; for(i=0;i<N;i++) cin >> D[i]; long long int ma = 0; for(i=0;i<N;i++) { ma = max(get_ans(C[i]-1, +1), ma); } cout << ma << '\n'; }

Compilation message (stderr)

toll.cpp: In function 'long long int get_ans(int, int)':
toll.cpp:46:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(i=0;i<V.size();i++) {
      |             ~^~~~~~~~~
toll.cpp:52:42: error: no matching function for call to 'std::vector<int>::push_back(std::array<long long int, 3>::value_type&, std::array<long long int, 3>::value_type&)'
   52 |         adj[it[2]].push_back(it[1], it[0]);
      |                                          ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from toll.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 2 provided
toll.cpp: In function 'int main()':
toll.cpp:64:12: warning: unused variable 'j' [-Wunused-variable]
   64 |     int i, j;
      |            ^