# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
550719 |
2022-04-18T21:40:52 Z |
Zhora_004 |
Graph (BOI20_graph) |
C++17 |
|
700 ms |
320 KB |
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#include <chrono>
#include <cassert>
#include <bitset>
#include <fstream>
//#include <bit>
//#include <ranges>
//#include <numbers>
#define itn int
#define sacnf scanf
#define sz(a) ((int)((a).size()))
// printf("%.10f\n", ans);
/*ofstream fout("timeline.out");
ifstream fin("timeline.in");*/
using ll = long long;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 2e5 + 1, inf = 1e9;
int n, m;
double ans = 1000;
vector<double> v, res;
vector<vector<int>> e;
double calc()
{
for (int i = 0; i < m; i++)
{
int a = e[i][0], b = e[i][1], c = e[i][2];
a--, b--;
if (v[a] + v[b] != c) return 1000;
}
double sum = 0;
for (int i = 0; i < n; i++) sum += abs(v[i]);
return sum;
}
void solve()
{
if (sz(v) == n)
{
double sum = calc();
if (sum < ans)
{
ans = sum;
res = v;
}
return;
}
for (double i = -5; i <= 5; i += 0.5)
{
v.push_back(i);
solve();
v.pop_back();
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
e = vector<vector<int>>(m, vector<int>(3));
for (int i = 0; i < m; i++) for (int j = 0; j < 3; j++) cin >> e[i][j];
solve();
if (ans != 1000)
{
cout << "YES\n";
for (double& i : res) cout << i << " ";
}
else cout << "NO\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
320 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
316 KB |
answer = NO |
5 |
Correct |
36 ms |
296 KB |
answer = YES |
6 |
Correct |
1 ms |
212 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
4 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
3 ms |
212 KB |
answer = YES |
11 |
Correct |
3 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
212 KB |
answer = NO |
13 |
Correct |
37 ms |
212 KB |
answer = YES |
14 |
Correct |
38 ms |
212 KB |
answer = YES |
15 |
Correct |
40 ms |
212 KB |
answer = YES |
16 |
Correct |
39 ms |
296 KB |
answer = YES |
17 |
Correct |
0 ms |
320 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
212 KB |
answer = YES |
21 |
Correct |
0 ms |
212 KB |
answer = YES |
22 |
Correct |
0 ms |
212 KB |
answer = NO |
23 |
Correct |
1 ms |
212 KB |
answer = NO |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
320 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
316 KB |
answer = NO |
5 |
Correct |
36 ms |
296 KB |
answer = YES |
6 |
Correct |
1 ms |
212 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
4 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
3 ms |
212 KB |
answer = YES |
11 |
Correct |
3 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
212 KB |
answer = NO |
13 |
Correct |
37 ms |
212 KB |
answer = YES |
14 |
Correct |
38 ms |
212 KB |
answer = YES |
15 |
Correct |
40 ms |
212 KB |
answer = YES |
16 |
Correct |
39 ms |
296 KB |
answer = YES |
17 |
Correct |
0 ms |
320 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
212 KB |
answer = YES |
21 |
Correct |
0 ms |
212 KB |
answer = YES |
22 |
Correct |
0 ms |
212 KB |
answer = NO |
23 |
Correct |
1 ms |
212 KB |
answer = NO |
24 |
Execution timed out |
1088 ms |
212 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
320 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
316 KB |
answer = NO |
5 |
Correct |
36 ms |
296 KB |
answer = YES |
6 |
Correct |
1 ms |
212 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
4 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
3 ms |
212 KB |
answer = YES |
11 |
Correct |
3 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
212 KB |
answer = NO |
13 |
Correct |
37 ms |
212 KB |
answer = YES |
14 |
Correct |
38 ms |
212 KB |
answer = YES |
15 |
Correct |
40 ms |
212 KB |
answer = YES |
16 |
Correct |
39 ms |
296 KB |
answer = YES |
17 |
Correct |
0 ms |
320 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
212 KB |
answer = YES |
21 |
Correct |
0 ms |
212 KB |
answer = YES |
22 |
Correct |
0 ms |
212 KB |
answer = NO |
23 |
Correct |
1 ms |
212 KB |
answer = NO |
24 |
Execution timed out |
1088 ms |
212 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
320 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
316 KB |
answer = NO |
5 |
Correct |
36 ms |
296 KB |
answer = YES |
6 |
Correct |
1 ms |
212 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
4 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
3 ms |
212 KB |
answer = YES |
11 |
Correct |
3 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
212 KB |
answer = NO |
13 |
Correct |
37 ms |
212 KB |
answer = YES |
14 |
Correct |
38 ms |
212 KB |
answer = YES |
15 |
Correct |
40 ms |
212 KB |
answer = YES |
16 |
Correct |
39 ms |
296 KB |
answer = YES |
17 |
Correct |
0 ms |
320 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
212 KB |
answer = YES |
21 |
Correct |
0 ms |
212 KB |
answer = YES |
22 |
Correct |
0 ms |
212 KB |
answer = NO |
23 |
Correct |
1 ms |
212 KB |
answer = NO |
24 |
Execution timed out |
1088 ms |
212 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
320 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
316 KB |
answer = NO |
5 |
Correct |
36 ms |
296 KB |
answer = YES |
6 |
Correct |
1 ms |
212 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
4 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
3 ms |
212 KB |
answer = YES |
11 |
Correct |
3 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
212 KB |
answer = NO |
13 |
Correct |
37 ms |
212 KB |
answer = YES |
14 |
Correct |
38 ms |
212 KB |
answer = YES |
15 |
Correct |
40 ms |
212 KB |
answer = YES |
16 |
Correct |
39 ms |
296 KB |
answer = YES |
17 |
Correct |
0 ms |
320 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
212 KB |
answer = YES |
21 |
Correct |
0 ms |
212 KB |
answer = YES |
22 |
Correct |
0 ms |
212 KB |
answer = NO |
23 |
Correct |
1 ms |
212 KB |
answer = NO |
24 |
Execution timed out |
1088 ms |
212 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |