# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1101797 |
2024-10-16T19:59:49 Z |
alexdd |
Graph (BOI20_graph) |
C++17 |
|
2 ms |
4436 KB |
#include <bits/stdc++.h>
using namespace std;
int n,m;
double val[100005];
int u[200005],v[200005],s[200005];
vector<pair<int,int>> con[100005];
bool visited[100005];
bool bun;
vector<int> aux;
void dfs(int nod)
{
aux.push_back(nod);
visited[nod]=1;
for(auto [adj,sum]:con[nod])
{
if(!visited[adj])
{
val[adj] = sum - val[nod];
dfs(adj);
}
else if(val[adj] != sum - val[nod])
bun = 0;
}
}
vector<double> possible = {0,0.5,1,1.5,2};
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>u[i]>>v[i]>>s[i];
con[u[i]].push_back({v[i],s[i]});
con[v[i]].push_back({u[i],s[i]});
}
for(int i=1;i<=n;i++)
{
visited[i]=0;
}
for(int i=1;i<=n;i++)
{
if(!visited[i])
{
for(double x:possible)
{
val[i] = x;
bun=1;
aux.clear();
dfs(i);
if(bun)
break;
for(int y:aux)
visited[y]=0;
}
if(!bun)
{
cout<<"NO";
return 0;
}
}
}
cout<<"YES\n";
for(int i=1;i<=n;i++)
cout<<val[i]<<" ";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4436 KB |
answer = YES |
2 |
Correct |
2 ms |
4436 KB |
answer = YES |
3 |
Correct |
1 ms |
4436 KB |
answer = YES |
4 |
Correct |
1 ms |
4436 KB |
answer = NO |
5 |
Correct |
1 ms |
4436 KB |
answer = YES |
6 |
Incorrect |
1 ms |
4436 KB |
participant answer is larger than the answer of jury |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4436 KB |
answer = YES |
2 |
Correct |
2 ms |
4436 KB |
answer = YES |
3 |
Correct |
1 ms |
4436 KB |
answer = YES |
4 |
Correct |
1 ms |
4436 KB |
answer = NO |
5 |
Correct |
1 ms |
4436 KB |
answer = YES |
6 |
Incorrect |
1 ms |
4436 KB |
participant answer is larger than the answer of jury |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4436 KB |
answer = YES |
2 |
Correct |
2 ms |
4436 KB |
answer = YES |
3 |
Correct |
1 ms |
4436 KB |
answer = YES |
4 |
Correct |
1 ms |
4436 KB |
answer = NO |
5 |
Correct |
1 ms |
4436 KB |
answer = YES |
6 |
Incorrect |
1 ms |
4436 KB |
participant answer is larger than the answer of jury |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4436 KB |
answer = YES |
2 |
Correct |
2 ms |
4436 KB |
answer = YES |
3 |
Correct |
1 ms |
4436 KB |
answer = YES |
4 |
Correct |
1 ms |
4436 KB |
answer = NO |
5 |
Correct |
1 ms |
4436 KB |
answer = YES |
6 |
Incorrect |
1 ms |
4436 KB |
participant answer is larger than the answer of jury |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4436 KB |
answer = YES |
2 |
Correct |
2 ms |
4436 KB |
answer = YES |
3 |
Correct |
1 ms |
4436 KB |
answer = YES |
4 |
Correct |
1 ms |
4436 KB |
answer = NO |
5 |
Correct |
1 ms |
4436 KB |
answer = YES |
6 |
Incorrect |
1 ms |
4436 KB |
participant answer is larger than the answer of jury |
7 |
Halted |
0 ms |
0 KB |
- |