Baltic Olympiad in Informatics 2020, Day 2 (IOI, Unofficial Mirror Contest, Unrated)


A. Graph
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2 1
2 3 2
1 3 2
3 4 1
Output
YES
0.5 0.5 1.5 -0.5
Input
2 1
1 2 1
Output
YES
0.3 0.7
Input
3 2
1 2 2
2 3 2
Output
YES
0 2 0
Input
3 4
1 2 2
2 2 1
2 1 1
1 2 2
Output
NO
----------------------------------------------------------------------------------------------------
B1. Village (Minimum)
time limit per test: 0.75 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
2 3
3 4
Output
4
2 1 4 3
Input
7
4 2
5 7
3 4
6 3
1 3
4 5
Output
8
3 4 6 2 7 1 5
----------------------------------------------------------------------------------------------------
B2. Village (Maximum)
time limit per test: 0.75 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
2 3
3 4
Output
8
4 3 2 1
Input
7
4 2
5 7
3 4
6 3
1 3
4 5
Output
18
2 7 4 1 3 5 6
----------------------------------------------------------------------------------------------------
C. Viruses
time limit per test: 0.75 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 6 2
2 2 0 1
3 3 2 0 0
3 2 1 3
4 4 0 3 1 2
5 2 2 1
5 1 5
2 1 1
5 0 0 1 0 0
Output
NO 2
NO 4
NO 9
YES
----------------------------------------------------------------------------------------------------
