This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#define lint long long
#define pb push_back
#define mp make_pair
using namespace std;
lint MOD = 1e9 + 7;
int INF = 1e9;
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){
vector<vector<int>> v(3, vector<int>(3, 0));
v[0][0] = 0;
v[1][1] = 0;
v[2][2] = 0;
// for(auto i : c){cout << i << " ";}
for(int i = 0; i < M; i ++){
v[x[i]][y[i]] = c[i];
v[y[i]][x[i]] = c[i];
}
// for(int i = 0; i < 3; i ++){
// for(int j = 0; j < 3; j ++){
// cout << v[i][j] << " ";
// }
// cout << endl;
// }
int sum1 = 0; // v[0][H]
if(arr[H] == 0){sum1 = 0;}
if(arr[H] == 1){sum1 += v[0][H];}
if(arr[H] == 2){sum1 += v[0][H]/2;}
// cout << c[H] << "sum1=" << sum1 << "\n\n\n";
int sum2 = 0; // v[0][3-H]+v[3-H][H]
if(arr[3-H] == 0){sum2 = 0;}
if(arr[3-H] == 1){sum2 += v[0][3-H];}
if(arr[3-H] == 2){sum2 += v[0][3-H]/2;}
if(arr[H] == 0){sum2 = 0;}
if(arr[H] == 1){sum2 += v[3-H][H];}
if(arr[H] == 2){sum2 += v[3-H][H]; sum2 /= 2;}
// cout << sum1 << " " << sum2 << endl << endl;
if(v[0][H] == 0) return sum2;
else if(v[0][3-H] == 0 || v[3-H][H] == 0){return sum1;}
else return min(sum1, sum2);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |