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<bits/stdc++.h>
using namespace std;
struct edge {
int u=0, v=0, type=0;
};
const int MAXN = 6, MAXM = 15;
int n, m;
vector<edge> e(MAXM);
vector<int> curr(MAXN);
vector<pair<long long, vector<int>>> answers;
bool brute(int in, long long sum) {
if(in == n) {
for(int i = 0;i<m;i++) {
if(curr[e[i].u] + curr[e[i].v] != 2*e[i].type)return false;
}
answers.push_back(make_pair(sum, curr));
return true;
}
else {
bool check = false;
for(int i = -10;i<=10;i++) {
curr[in] = i;
check|=brute(in+1, sum+i);
}
return check;
}
}
int main () {
cin >> n >> m;
for(int i = 0;i<m;i++) {
cin >> e[i].u >> e[i].v >> e[i].type;
e[i].u--, e[i].v--;
}
if(n <= 5 and m<=14) {
if(!brute(0, 0))cout << "NO\n";
else {
sort(answers.begin(), answers.end());
cout << "YES\n";
for(int i = 0;i<n;i++) {
cout << 0.5*answers[0].second[i] << " ";
}
cout << "\n";
}
}
}
# | 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... |