# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1101975 |
2024-10-17T08:54:49 Z |
epicci23 |
Graph (BOI20_graph) |
C++17 |
|
140 ms |
26056 KB |
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define all(v) v.begin() , v.end()
#define sz(a) ((int)a.size())
const int N = 1e5 + 5;
vector<array<int,2>> v[N];
double ans[N];
bool vis[N],vis2[N];
array<int,2> line[N];
int koy=-1;
double val=-1;
vector<int> node;
void upd(int ind,int a,int b){
if(line[ind][0]==0){
line[ind]={a,b};
return;
}
if(line[ind][0]==a && b!=line[ind][1]){
cout << "NO\n";
exit(0);
}
if(line[ind][0]==a) return;
koy=ind;
val=(b+line[ind][1])/2.0L;
}
void dfs(int c){
vis[c]=1;
node.push_back(c);
for(auto E:v[c]){
int x=E[0],u=E[1];
upd(x,-line[c][0],-line[c][1]+u);
if(vis[x]) continue;
dfs(x);
}
}
void dfs2(int c,double val){
ans[c]=val;
vis[c]=vis2[c]=1;
for(auto E:v[c]){
int x=E[0],u=E[1];
if(vis2[x]){
if(u-val!=ans[x]){
cout << "NO\n";
exit(0);
}
continue;
}
else dfs2(x,u-val);
}
}
void _(){
int n,m;
cin >> n >> m;
for(int i=1;i<=m;i++){
int a,b,c;
cin >> a >> b >> c;
v[a].push_back({b,c});
v[b].push_back({a,c});
}
for(int i=1;i<=n;i++){
if(vis[i]) continue;
koy=-1;
node.clear();
upd(i,1,0);
dfs(i);
if(koy!=-1) dfs2(koy,val);
else{
vector<int> S;
for(int x:node){
if(line[x][0]==1) S.push_back(-line[x][1]);
else S.push_back(line[x][1]);
}
sort(all(S));
dfs2(i,line[i][0]*S[sz(S)/2]+line[i][1]);
}
}
cout << "YES\n";
for(int i=1;i<=n;i++) cout << ans[i] << " \n"[i==n];
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
cout << fixed << setprecision(16);
int tc=1;//cin >> tc;
while(tc--) _();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3920 KB |
answer = YES |
2 |
Correct |
2 ms |
3920 KB |
answer = YES |
3 |
Correct |
2 ms |
3920 KB |
answer = YES |
4 |
Correct |
2 ms |
3832 KB |
answer = NO |
5 |
Correct |
2 ms |
3920 KB |
answer = YES |
6 |
Correct |
2 ms |
3920 KB |
answer = YES |
7 |
Correct |
2 ms |
3920 KB |
answer = YES |
8 |
Correct |
2 ms |
3920 KB |
answer = YES |
9 |
Correct |
2 ms |
3664 KB |
answer = NO |
10 |
Correct |
2 ms |
3920 KB |
answer = YES |
11 |
Correct |
2 ms |
3920 KB |
answer = YES |
12 |
Correct |
2 ms |
3664 KB |
answer = NO |
13 |
Correct |
2 ms |
3920 KB |
answer = YES |
14 |
Correct |
2 ms |
4092 KB |
answer = YES |
15 |
Correct |
2 ms |
3920 KB |
answer = YES |
16 |
Correct |
2 ms |
3920 KB |
answer = YES |
17 |
Correct |
2 ms |
3920 KB |
answer = YES |
18 |
Correct |
2 ms |
3920 KB |
answer = YES |
19 |
Correct |
2 ms |
3920 KB |
answer = YES |
20 |
Correct |
2 ms |
3920 KB |
answer = YES |
21 |
Correct |
2 ms |
3920 KB |
answer = YES |
22 |
Correct |
2 ms |
3664 KB |
answer = NO |
23 |
Correct |
2 ms |
3920 KB |
answer = NO |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3920 KB |
answer = YES |
2 |
Correct |
2 ms |
3920 KB |
answer = YES |
3 |
Correct |
2 ms |
3920 KB |
answer = YES |
4 |
Correct |
2 ms |
3832 KB |
answer = NO |
5 |
Correct |
2 ms |
3920 KB |
answer = YES |
6 |
Correct |
2 ms |
3920 KB |
answer = YES |
7 |
Correct |
2 ms |
3920 KB |
answer = YES |
8 |
Correct |
2 ms |
3920 KB |
answer = YES |
9 |
Correct |
2 ms |
3664 KB |
answer = NO |
10 |
Correct |
2 ms |
3920 KB |
answer = YES |
11 |
Correct |
2 ms |
3920 KB |
answer = YES |
12 |
Correct |
2 ms |
3664 KB |
answer = NO |
13 |
Correct |
2 ms |
3920 KB |
answer = YES |
14 |
Correct |
2 ms |
4092 KB |
answer = YES |
15 |
Correct |
2 ms |
3920 KB |
answer = YES |
16 |
Correct |
2 ms |
3920 KB |
answer = YES |
17 |
Correct |
2 ms |
3920 KB |
answer = YES |
18 |
Correct |
2 ms |
3920 KB |
answer = YES |
19 |
Correct |
2 ms |
3920 KB |
answer = YES |
20 |
Correct |
2 ms |
3920 KB |
answer = YES |
21 |
Correct |
2 ms |
3920 KB |
answer = YES |
22 |
Correct |
2 ms |
3664 KB |
answer = NO |
23 |
Correct |
2 ms |
3920 KB |
answer = NO |
24 |
Correct |
2 ms |
3920 KB |
answer = YES |
25 |
Correct |
2 ms |
3920 KB |
answer = YES |
26 |
Correct |
2 ms |
3920 KB |
answer = YES |
27 |
Correct |
2 ms |
3920 KB |
answer = YES |
28 |
Correct |
2 ms |
3920 KB |
answer = YES |
29 |
Correct |
3 ms |
3920 KB |
answer = YES |
30 |
Correct |
2 ms |
4088 KB |
answer = NO |
31 |
Correct |
2 ms |
3920 KB |
answer = YES |
32 |
Correct |
3 ms |
3920 KB |
answer = YES |
33 |
Correct |
2 ms |
3920 KB |
answer = YES |
34 |
Correct |
2 ms |
3920 KB |
answer = YES |
35 |
Correct |
2 ms |
3920 KB |
answer = YES |
36 |
Correct |
2 ms |
3812 KB |
answer = YES |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3920 KB |
answer = YES |
2 |
Correct |
2 ms |
3920 KB |
answer = YES |
3 |
Correct |
2 ms |
3920 KB |
answer = YES |
4 |
Correct |
2 ms |
3832 KB |
answer = NO |
5 |
Correct |
2 ms |
3920 KB |
answer = YES |
6 |
Correct |
2 ms |
3920 KB |
answer = YES |
7 |
Correct |
2 ms |
3920 KB |
answer = YES |
8 |
Correct |
2 ms |
3920 KB |
answer = YES |
9 |
Correct |
2 ms |
3664 KB |
answer = NO |
10 |
Correct |
2 ms |
3920 KB |
answer = YES |
11 |
Correct |
2 ms |
3920 KB |
answer = YES |
12 |
Correct |
2 ms |
3664 KB |
answer = NO |
13 |
Correct |
2 ms |
3920 KB |
answer = YES |
14 |
Correct |
2 ms |
4092 KB |
answer = YES |
15 |
Correct |
2 ms |
3920 KB |
answer = YES |
16 |
Correct |
2 ms |
3920 KB |
answer = YES |
17 |
Correct |
2 ms |
3920 KB |
answer = YES |
18 |
Correct |
2 ms |
3920 KB |
answer = YES |
19 |
Correct |
2 ms |
3920 KB |
answer = YES |
20 |
Correct |
2 ms |
3920 KB |
answer = YES |
21 |
Correct |
2 ms |
3920 KB |
answer = YES |
22 |
Correct |
2 ms |
3664 KB |
answer = NO |
23 |
Correct |
2 ms |
3920 KB |
answer = NO |
24 |
Correct |
2 ms |
3920 KB |
answer = YES |
25 |
Correct |
2 ms |
3920 KB |
answer = YES |
26 |
Correct |
2 ms |
3920 KB |
answer = YES |
27 |
Correct |
2 ms |
3920 KB |
answer = YES |
28 |
Correct |
2 ms |
3920 KB |
answer = YES |
29 |
Correct |
3 ms |
3920 KB |
answer = YES |
30 |
Correct |
2 ms |
4088 KB |
answer = NO |
31 |
Correct |
2 ms |
3920 KB |
answer = YES |
32 |
Correct |
3 ms |
3920 KB |
answer = YES |
33 |
Correct |
2 ms |
3920 KB |
answer = YES |
34 |
Correct |
2 ms |
3920 KB |
answer = YES |
35 |
Correct |
2 ms |
3920 KB |
answer = YES |
36 |
Correct |
2 ms |
3812 KB |
answer = YES |
37 |
Correct |
3 ms |
3920 KB |
answer = YES |
38 |
Correct |
2 ms |
3920 KB |
answer = YES |
39 |
Correct |
2 ms |
4088 KB |
answer = YES |
40 |
Correct |
3 ms |
3920 KB |
answer = YES |
41 |
Correct |
2 ms |
3920 KB |
answer = NO |
42 |
Correct |
3 ms |
3932 KB |
answer = YES |
43 |
Correct |
3 ms |
3932 KB |
answer = YES |
44 |
Correct |
2 ms |
3932 KB |
answer = YES |
45 |
Correct |
2 ms |
3932 KB |
answer = YES |
46 |
Correct |
3 ms |
4088 KB |
answer = YES |
47 |
Correct |
3 ms |
3920 KB |
answer = YES |
48 |
Correct |
2 ms |
3920 KB |
answer = YES |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3920 KB |
answer = YES |
2 |
Correct |
2 ms |
3920 KB |
answer = YES |
3 |
Correct |
2 ms |
3920 KB |
answer = YES |
4 |
Correct |
2 ms |
3832 KB |
answer = NO |
5 |
Correct |
2 ms |
3920 KB |
answer = YES |
6 |
Correct |
2 ms |
3920 KB |
answer = YES |
7 |
Correct |
2 ms |
3920 KB |
answer = YES |
8 |
Correct |
2 ms |
3920 KB |
answer = YES |
9 |
Correct |
2 ms |
3664 KB |
answer = NO |
10 |
Correct |
2 ms |
3920 KB |
answer = YES |
11 |
Correct |
2 ms |
3920 KB |
answer = YES |
12 |
Correct |
2 ms |
3664 KB |
answer = NO |
13 |
Correct |
2 ms |
3920 KB |
answer = YES |
14 |
Correct |
2 ms |
4092 KB |
answer = YES |
15 |
Correct |
2 ms |
3920 KB |
answer = YES |
16 |
Correct |
2 ms |
3920 KB |
answer = YES |
17 |
Correct |
2 ms |
3920 KB |
answer = YES |
18 |
Correct |
2 ms |
3920 KB |
answer = YES |
19 |
Correct |
2 ms |
3920 KB |
answer = YES |
20 |
Correct |
2 ms |
3920 KB |
answer = YES |
21 |
Correct |
2 ms |
3920 KB |
answer = YES |
22 |
Correct |
2 ms |
3664 KB |
answer = NO |
23 |
Correct |
2 ms |
3920 KB |
answer = NO |
24 |
Correct |
2 ms |
3920 KB |
answer = YES |
25 |
Correct |
2 ms |
3920 KB |
answer = YES |
26 |
Correct |
2 ms |
3920 KB |
answer = YES |
27 |
Correct |
2 ms |
3920 KB |
answer = YES |
28 |
Correct |
2 ms |
3920 KB |
answer = YES |
29 |
Correct |
3 ms |
3920 KB |
answer = YES |
30 |
Correct |
2 ms |
4088 KB |
answer = NO |
31 |
Correct |
2 ms |
3920 KB |
answer = YES |
32 |
Correct |
3 ms |
3920 KB |
answer = YES |
33 |
Correct |
2 ms |
3920 KB |
answer = YES |
34 |
Correct |
2 ms |
3920 KB |
answer = YES |
35 |
Correct |
2 ms |
3920 KB |
answer = YES |
36 |
Correct |
2 ms |
3812 KB |
answer = YES |
37 |
Correct |
3 ms |
3920 KB |
answer = YES |
38 |
Correct |
2 ms |
3920 KB |
answer = YES |
39 |
Correct |
2 ms |
4088 KB |
answer = YES |
40 |
Correct |
3 ms |
3920 KB |
answer = YES |
41 |
Correct |
2 ms |
3920 KB |
answer = NO |
42 |
Correct |
3 ms |
3932 KB |
answer = YES |
43 |
Correct |
3 ms |
3932 KB |
answer = YES |
44 |
Correct |
2 ms |
3932 KB |
answer = YES |
45 |
Correct |
2 ms |
3932 KB |
answer = YES |
46 |
Correct |
3 ms |
4088 KB |
answer = YES |
47 |
Correct |
3 ms |
3920 KB |
answer = YES |
48 |
Correct |
2 ms |
3920 KB |
answer = YES |
49 |
Correct |
9 ms |
5120 KB |
answer = YES |
50 |
Correct |
9 ms |
5456 KB |
answer = YES |
51 |
Correct |
9 ms |
5376 KB |
answer = YES |
52 |
Correct |
5 ms |
4604 KB |
answer = NO |
53 |
Correct |
2 ms |
3920 KB |
answer = YES |
54 |
Correct |
4 ms |
4176 KB |
answer = YES |
55 |
Correct |
5 ms |
4432 KB |
answer = YES |
56 |
Correct |
8 ms |
5136 KB |
answer = YES |
57 |
Correct |
8 ms |
4944 KB |
answer = YES |
58 |
Correct |
8 ms |
4944 KB |
answer = YES |
59 |
Correct |
8 ms |
4944 KB |
answer = YES |
60 |
Correct |
15 ms |
4944 KB |
answer = YES |
61 |
Correct |
5 ms |
4432 KB |
answer = YES |
62 |
Correct |
41 ms |
12984 KB |
answer = NO |
63 |
Correct |
51 ms |
13896 KB |
answer = YES |
64 |
Correct |
46 ms |
13896 KB |
answer = NO |
65 |
Correct |
50 ms |
13904 KB |
answer = YES |
66 |
Correct |
3 ms |
4092 KB |
answer = YES |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3920 KB |
answer = YES |
2 |
Correct |
2 ms |
3920 KB |
answer = YES |
3 |
Correct |
2 ms |
3920 KB |
answer = YES |
4 |
Correct |
2 ms |
3832 KB |
answer = NO |
5 |
Correct |
2 ms |
3920 KB |
answer = YES |
6 |
Correct |
2 ms |
3920 KB |
answer = YES |
7 |
Correct |
2 ms |
3920 KB |
answer = YES |
8 |
Correct |
2 ms |
3920 KB |
answer = YES |
9 |
Correct |
2 ms |
3664 KB |
answer = NO |
10 |
Correct |
2 ms |
3920 KB |
answer = YES |
11 |
Correct |
2 ms |
3920 KB |
answer = YES |
12 |
Correct |
2 ms |
3664 KB |
answer = NO |
13 |
Correct |
2 ms |
3920 KB |
answer = YES |
14 |
Correct |
2 ms |
4092 KB |
answer = YES |
15 |
Correct |
2 ms |
3920 KB |
answer = YES |
16 |
Correct |
2 ms |
3920 KB |
answer = YES |
17 |
Correct |
2 ms |
3920 KB |
answer = YES |
18 |
Correct |
2 ms |
3920 KB |
answer = YES |
19 |
Correct |
2 ms |
3920 KB |
answer = YES |
20 |
Correct |
2 ms |
3920 KB |
answer = YES |
21 |
Correct |
2 ms |
3920 KB |
answer = YES |
22 |
Correct |
2 ms |
3664 KB |
answer = NO |
23 |
Correct |
2 ms |
3920 KB |
answer = NO |
24 |
Correct |
2 ms |
3920 KB |
answer = YES |
25 |
Correct |
2 ms |
3920 KB |
answer = YES |
26 |
Correct |
2 ms |
3920 KB |
answer = YES |
27 |
Correct |
2 ms |
3920 KB |
answer = YES |
28 |
Correct |
2 ms |
3920 KB |
answer = YES |
29 |
Correct |
3 ms |
3920 KB |
answer = YES |
30 |
Correct |
2 ms |
4088 KB |
answer = NO |
31 |
Correct |
2 ms |
3920 KB |
answer = YES |
32 |
Correct |
3 ms |
3920 KB |
answer = YES |
33 |
Correct |
2 ms |
3920 KB |
answer = YES |
34 |
Correct |
2 ms |
3920 KB |
answer = YES |
35 |
Correct |
2 ms |
3920 KB |
answer = YES |
36 |
Correct |
2 ms |
3812 KB |
answer = YES |
37 |
Correct |
3 ms |
3920 KB |
answer = YES |
38 |
Correct |
2 ms |
3920 KB |
answer = YES |
39 |
Correct |
2 ms |
4088 KB |
answer = YES |
40 |
Correct |
3 ms |
3920 KB |
answer = YES |
41 |
Correct |
2 ms |
3920 KB |
answer = NO |
42 |
Correct |
3 ms |
3932 KB |
answer = YES |
43 |
Correct |
3 ms |
3932 KB |
answer = YES |
44 |
Correct |
2 ms |
3932 KB |
answer = YES |
45 |
Correct |
2 ms |
3932 KB |
answer = YES |
46 |
Correct |
3 ms |
4088 KB |
answer = YES |
47 |
Correct |
3 ms |
3920 KB |
answer = YES |
48 |
Correct |
2 ms |
3920 KB |
answer = YES |
49 |
Correct |
9 ms |
5120 KB |
answer = YES |
50 |
Correct |
9 ms |
5456 KB |
answer = YES |
51 |
Correct |
9 ms |
5376 KB |
answer = YES |
52 |
Correct |
5 ms |
4604 KB |
answer = NO |
53 |
Correct |
2 ms |
3920 KB |
answer = YES |
54 |
Correct |
4 ms |
4176 KB |
answer = YES |
55 |
Correct |
5 ms |
4432 KB |
answer = YES |
56 |
Correct |
8 ms |
5136 KB |
answer = YES |
57 |
Correct |
8 ms |
4944 KB |
answer = YES |
58 |
Correct |
8 ms |
4944 KB |
answer = YES |
59 |
Correct |
8 ms |
4944 KB |
answer = YES |
60 |
Correct |
15 ms |
4944 KB |
answer = YES |
61 |
Correct |
5 ms |
4432 KB |
answer = YES |
62 |
Correct |
41 ms |
12984 KB |
answer = NO |
63 |
Correct |
51 ms |
13896 KB |
answer = YES |
64 |
Correct |
46 ms |
13896 KB |
answer = NO |
65 |
Correct |
50 ms |
13904 KB |
answer = YES |
66 |
Correct |
3 ms |
4092 KB |
answer = YES |
67 |
Correct |
86 ms |
19952 KB |
answer = YES |
68 |
Correct |
70 ms |
19752 KB |
answer = YES |
69 |
Correct |
67 ms |
19900 KB |
answer = YES |
70 |
Correct |
97 ms |
26056 KB |
answer = YES |
71 |
Correct |
69 ms |
19904 KB |
answer = YES |
72 |
Correct |
76 ms |
13868 KB |
answer = YES |
73 |
Correct |
71 ms |
14068 KB |
answer = YES |
74 |
Correct |
53 ms |
13676 KB |
answer = YES |
75 |
Correct |
19 ms |
9936 KB |
answer = NO |
76 |
Correct |
10 ms |
5360 KB |
answer = YES |
77 |
Correct |
19 ms |
6788 KB |
answer = YES |
78 |
Correct |
32 ms |
8432 KB |
answer = YES |
79 |
Correct |
62 ms |
12452 KB |
answer = YES |
80 |
Correct |
54 ms |
13648 KB |
answer = YES |
81 |
Correct |
31 ms |
14144 KB |
answer = NO |
82 |
Correct |
81 ms |
19388 KB |
answer = YES |
83 |
Correct |
96 ms |
20424 KB |
answer = YES |
84 |
Correct |
106 ms |
20524 KB |
answer = YES |
85 |
Correct |
77 ms |
19928 KB |
answer = YES |
86 |
Correct |
83 ms |
19900 KB |
answer = YES |
87 |
Correct |
48 ms |
13352 KB |
answer = NO |
88 |
Correct |
110 ms |
16320 KB |
answer = YES |
89 |
Correct |
74 ms |
12616 KB |
answer = YES |
90 |
Correct |
76 ms |
12624 KB |
answer = YES |
91 |
Correct |
77 ms |
13128 KB |
answer = YES |
92 |
Correct |
37 ms |
9152 KB |
answer = YES |
93 |
Correct |
38 ms |
9160 KB |
answer = YES |
94 |
Correct |
58 ms |
17852 KB |
answer = NO |
95 |
Correct |
32 ms |
11384 KB |
answer = NO |
96 |
Correct |
140 ms |
22976 KB |
answer = YES |
97 |
Correct |
38 ms |
17240 KB |
answer = NO |