Submission #1041740

#TimeUsernameProblemLanguageResultExecution timeMemory
1041740MuhammetSwapping Cities (APIO20_swap)C++17
0 / 100
56 ms7988 KiB
#include <bits/stdc++.h> #include "swap.h" using namespace std; const int N = 100005; int n, m, v[N]; vector <int> v2; void init(int n1, int m1, vector<int> u1, vector<int> v1, vector<int> w1) { for(int i = 0; i < m1; i++){ v[v1[i]] = (w1[i]); v2.push_back(w1[i]); } sort(v2.begin(), v2.end()); } int getMinimumFuelCapacity(int x, int y) { if(m <= 2){ return -1; } if(x > y) swap(x,y); int ans = (v[x]+v[y]); bool tr = 0, tr1 = 0; for(int i = 0; i <= 5; i++){ if((v2[i] != v[x] and v2[i] != v[y]) or (v2[i] == v[x] and ((tr == 1 and v[y] != v[x]) or (v[y] == v[x] and tr1 == 1))) or (v2[i] == v[y] and ((tr1 == 1 and v[y] != v[x]) or (v[y] == v[x] and tr == 1)))){ ans += (2*v2[i]); break; } if(v2[i] == v[x]) tr = 1; else if(v2[i] == v[y]) tr1 = 1; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...