Submission #859307

# Submission time Handle Problem Language Result Execution time Memory
859307 2023-10-10T03:44:00 Z maks007 Graph (BOI20_graph) C++14
5 / 100
700 ms 456 KB
#include "bits/stdc++.h"

using namespace std;

#define int long long

signed main () {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector <pair <int, double>> g[n];
	vector <double> node(n, (double)1e9), ans(n);
	double mn = 1e9;
	function<void(int)> rec=[&](int i) {
		// cout << i << " ";
		if(i==n) {
			for(int j = 0; j < n; j ++) {
				for(auto [k, w] : g[j]) {
					if(node[k] + node[j] == w) continue;
					return;
				}
			}
			double sum = 0.0;
			for(auto i : node) sum += fabs(i);
			// cout << mn << " ";
			if(sum < mn) {
				ans = node;
			
				mn = min(mn, sum);
			}
			return;
		}
		for(double val = -2; val < 3; val += 0.25) {
			node[i] = val;
			rec(i+1);
			node[i] = 1e9;
		}
	};
	for(int i = 0; i < m; i ++) {
		int u, v;
		cin >> u >> v;
		u --, v --;
		int w;
		cin >> w;
		g[u].push_back({v, w});
		g[v].push_back({u, w});
	}
	rec(0);
	if(mn == 1e9) {
		cout << "NO\n";
		return 0;
	}
	cout << "YES" << "\n";
	for(auto i : ans) cout << fixed << setprecision(6) << i << " ";
	return 0;
}

Compilation message

Graph.cpp: In lambda function:
Graph.cpp:19:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   19 |     for(auto [k, w] : g[j]) {
      |              ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB answer = YES
2 Correct 0 ms 348 KB answer = YES
3 Correct 0 ms 452 KB answer = YES
4 Correct 1 ms 348 KB answer = NO
5 Correct 24 ms 344 KB answer = YES
6 Correct 0 ms 348 KB answer = YES
7 Correct 0 ms 348 KB answer = YES
8 Correct 2 ms 348 KB answer = YES
9 Correct 1 ms 348 KB answer = NO
10 Correct 2 ms 348 KB answer = YES
11 Correct 2 ms 348 KB answer = YES
12 Correct 1 ms 348 KB answer = NO
13 Correct 23 ms 456 KB answer = YES
14 Correct 23 ms 344 KB answer = YES
15 Correct 23 ms 436 KB answer = YES
16 Correct 23 ms 348 KB answer = YES
17 Correct 0 ms 348 KB answer = YES
18 Correct 0 ms 348 KB answer = YES
19 Correct 1 ms 348 KB answer = YES
20 Correct 0 ms 344 KB answer = YES
21 Correct 0 ms 348 KB answer = YES
22 Correct 0 ms 348 KB answer = NO
23 Correct 1 ms 344 KB answer = NO
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB answer = YES
2 Correct 0 ms 348 KB answer = YES
3 Correct 0 ms 452 KB answer = YES
4 Correct 1 ms 348 KB answer = NO
5 Correct 24 ms 344 KB answer = YES
6 Correct 0 ms 348 KB answer = YES
7 Correct 0 ms 348 KB answer = YES
8 Correct 2 ms 348 KB answer = YES
9 Correct 1 ms 348 KB answer = NO
10 Correct 2 ms 348 KB answer = YES
11 Correct 2 ms 348 KB answer = YES
12 Correct 1 ms 348 KB answer = NO
13 Correct 23 ms 456 KB answer = YES
14 Correct 23 ms 344 KB answer = YES
15 Correct 23 ms 436 KB answer = YES
16 Correct 23 ms 348 KB answer = YES
17 Correct 0 ms 348 KB answer = YES
18 Correct 0 ms 348 KB answer = YES
19 Correct 1 ms 348 KB answer = YES
20 Correct 0 ms 344 KB answer = YES
21 Correct 0 ms 348 KB answer = YES
22 Correct 0 ms 348 KB answer = NO
23 Correct 1 ms 344 KB answer = NO
24 Execution timed out 1016 ms 348 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB answer = YES
2 Correct 0 ms 348 KB answer = YES
3 Correct 0 ms 452 KB answer = YES
4 Correct 1 ms 348 KB answer = NO
5 Correct 24 ms 344 KB answer = YES
6 Correct 0 ms 348 KB answer = YES
7 Correct 0 ms 348 KB answer = YES
8 Correct 2 ms 348 KB answer = YES
9 Correct 1 ms 348 KB answer = NO
10 Correct 2 ms 348 KB answer = YES
11 Correct 2 ms 348 KB answer = YES
12 Correct 1 ms 348 KB answer = NO
13 Correct 23 ms 456 KB answer = YES
14 Correct 23 ms 344 KB answer = YES
15 Correct 23 ms 436 KB answer = YES
16 Correct 23 ms 348 KB answer = YES
17 Correct 0 ms 348 KB answer = YES
18 Correct 0 ms 348 KB answer = YES
19 Correct 1 ms 348 KB answer = YES
20 Correct 0 ms 344 KB answer = YES
21 Correct 0 ms 348 KB answer = YES
22 Correct 0 ms 348 KB answer = NO
23 Correct 1 ms 344 KB answer = NO
24 Execution timed out 1016 ms 348 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB answer = YES
2 Correct 0 ms 348 KB answer = YES
3 Correct 0 ms 452 KB answer = YES
4 Correct 1 ms 348 KB answer = NO
5 Correct 24 ms 344 KB answer = YES
6 Correct 0 ms 348 KB answer = YES
7 Correct 0 ms 348 KB answer = YES
8 Correct 2 ms 348 KB answer = YES
9 Correct 1 ms 348 KB answer = NO
10 Correct 2 ms 348 KB answer = YES
11 Correct 2 ms 348 KB answer = YES
12 Correct 1 ms 348 KB answer = NO
13 Correct 23 ms 456 KB answer = YES
14 Correct 23 ms 344 KB answer = YES
15 Correct 23 ms 436 KB answer = YES
16 Correct 23 ms 348 KB answer = YES
17 Correct 0 ms 348 KB answer = YES
18 Correct 0 ms 348 KB answer = YES
19 Correct 1 ms 348 KB answer = YES
20 Correct 0 ms 344 KB answer = YES
21 Correct 0 ms 348 KB answer = YES
22 Correct 0 ms 348 KB answer = NO
23 Correct 1 ms 344 KB answer = NO
24 Execution timed out 1016 ms 348 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB answer = YES
2 Correct 0 ms 348 KB answer = YES
3 Correct 0 ms 452 KB answer = YES
4 Correct 1 ms 348 KB answer = NO
5 Correct 24 ms 344 KB answer = YES
6 Correct 0 ms 348 KB answer = YES
7 Correct 0 ms 348 KB answer = YES
8 Correct 2 ms 348 KB answer = YES
9 Correct 1 ms 348 KB answer = NO
10 Correct 2 ms 348 KB answer = YES
11 Correct 2 ms 348 KB answer = YES
12 Correct 1 ms 348 KB answer = NO
13 Correct 23 ms 456 KB answer = YES
14 Correct 23 ms 344 KB answer = YES
15 Correct 23 ms 436 KB answer = YES
16 Correct 23 ms 348 KB answer = YES
17 Correct 0 ms 348 KB answer = YES
18 Correct 0 ms 348 KB answer = YES
19 Correct 1 ms 348 KB answer = YES
20 Correct 0 ms 344 KB answer = YES
21 Correct 0 ms 348 KB answer = YES
22 Correct 0 ms 348 KB answer = NO
23 Correct 1 ms 344 KB answer = NO
24 Execution timed out 1016 ms 348 KB Time limit exceeded
25 Halted 0 ms 0 KB -