# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
605020 |
2022-07-25T12:20:01 Z |
OttoTheDino |
Graph (BOI20_graph) |
C++17 |
|
5 ms |
7424 KB |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for (ll i = s; i <= e; ++i)
#define pb push_back
#define len(a) (ll)a.size()
typedef long long ll;
typedef vector<pair<ll,ll>> vpll;
const ll mx = 3e5;
vpll cur, adj[mx+1];
ll coeff[mx+1], ans[mx+1], suc = 1, been[mx+1], c[mx+1];
set<ll> st;
void dfs (ll u, ll p) {
cur.pb({coeff[u], u});
for (auto [v,e] : adj[u]) {
if (e==p) continue;
if (been[v]) {
if (been[v]==been[u]) st.insert(been[u]*(c[e]-coeff[u]-coeff[v])/2);
else if (coeff[v]!=c[e]) suc = 0;
continue;
}
been[v] = been[u]*-1;
coeff[v] = c[e]-coeff[u];
dfs (v,e);
}
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
ll n, m; cin >> n >> m;
rep (i,1,m) {
ll u, v; cin >> u >> v;
adj[u].pb({v,i});
adj[v].pb({u,i});
cin >> c[i];
c[i] *= 2;
}
rep (i,1,n) {
if (been[i]) continue;
been[i] = 1;
dfs (i,0);
ll x = -1;
if (len(st)>1) {
suc =0;
break;
}
else if (len(st)==1) x = *st.begin();
else {
vpll changes;
ll best = 5e18;
rep (j,-100,100) {
ll cand = 0;
for (auto [val, u] : cur) cand = abs(val+been[u]*j);
if (cand<best) x = j;
}
}
for (auto [val, u] : cur) ans[u] = val+been[u]*x;
cur.clear();
}
if (suc) {
cout << "YES\n";
rep (i,1,n) cout << ans[i]/2.0 << " \n"[i==n];
}
else cout << "NO\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
answer = YES |
2 |
Incorrect |
5 ms |
7424 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
answer = YES |
2 |
Incorrect |
5 ms |
7424 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
answer = YES |
2 |
Incorrect |
5 ms |
7424 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
answer = YES |
2 |
Incorrect |
5 ms |
7424 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
7380 KB |
answer = YES |
2 |
Incorrect |
5 ms |
7424 KB |
participant answer is larger than the answer of jury |
3 |
Halted |
0 ms |
0 KB |
- |