# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
556434 |
2022-05-03T06:51:19 Z |
fuad27 |
Graph (BOI20_graph) |
C++17 |
|
28 ms |
632 KB |
#include<bits/stdc++.h>
using namespace std;
struct edge {
int u=0, v=0, type=0;
};
const int MAXN = 6, MAXM = 15;
int n, m;
vector<edge> e(MAXM);
vector<int> curr(MAXN);
vector<pair<long long, vector<int>>> answers;
bool brute(int in, long long sum) {
if(in == n) {
for(int i = 0;i<m;i++) {
if(curr[e[i].u] + curr[e[i].v] != 2*e[i].type)return false;
}
answers.push_back(make_pair(sum, curr));
return true;
}
else {
bool check = false;
for(int i = -10;i<=10;i++) {
curr[in] = i;
check|=brute(in+1, sum+abs(i));
}
return check;
}
}
int main () {
cin >> n >> m;
for(int i = 0;i<m;i++) {
cin >> e[i].u >> e[i].v >> e[i].type;
e[i].u--, e[i].v--;
}
if(n <= 5 and m<=14) {
if(!brute(0, 0))cout << "NO\n";
else {
sort(answers.begin(), answers.end());
cout << "YES\n";
for(int i = 0;i<n;i++) {
cout << 0.5*answers[0].second[i] << " ";
}
cout << "\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
212 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
212 KB |
answer = NO |
5 |
Correct |
27 ms |
632 KB |
answer = YES |
6 |
Correct |
0 ms |
300 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
2 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
2 ms |
304 KB |
answer = YES |
11 |
Correct |
1 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
300 KB |
answer = NO |
13 |
Correct |
23 ms |
212 KB |
answer = YES |
14 |
Correct |
25 ms |
300 KB |
answer = YES |
15 |
Correct |
25 ms |
292 KB |
answer = YES |
16 |
Correct |
28 ms |
212 KB |
answer = YES |
17 |
Correct |
0 ms |
212 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
300 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 |
1 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
212 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
212 KB |
answer = NO |
5 |
Correct |
27 ms |
632 KB |
answer = YES |
6 |
Correct |
0 ms |
300 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
2 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
2 ms |
304 KB |
answer = YES |
11 |
Correct |
1 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
300 KB |
answer = NO |
13 |
Correct |
23 ms |
212 KB |
answer = YES |
14 |
Correct |
25 ms |
300 KB |
answer = YES |
15 |
Correct |
25 ms |
292 KB |
answer = YES |
16 |
Correct |
28 ms |
212 KB |
answer = YES |
17 |
Correct |
0 ms |
212 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
300 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 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
212 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
212 KB |
answer = NO |
5 |
Correct |
27 ms |
632 KB |
answer = YES |
6 |
Correct |
0 ms |
300 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
2 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
2 ms |
304 KB |
answer = YES |
11 |
Correct |
1 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
300 KB |
answer = NO |
13 |
Correct |
23 ms |
212 KB |
answer = YES |
14 |
Correct |
25 ms |
300 KB |
answer = YES |
15 |
Correct |
25 ms |
292 KB |
answer = YES |
16 |
Correct |
28 ms |
212 KB |
answer = YES |
17 |
Correct |
0 ms |
212 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
300 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 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
212 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
212 KB |
answer = NO |
5 |
Correct |
27 ms |
632 KB |
answer = YES |
6 |
Correct |
0 ms |
300 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
2 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
2 ms |
304 KB |
answer = YES |
11 |
Correct |
1 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
300 KB |
answer = NO |
13 |
Correct |
23 ms |
212 KB |
answer = YES |
14 |
Correct |
25 ms |
300 KB |
answer = YES |
15 |
Correct |
25 ms |
292 KB |
answer = YES |
16 |
Correct |
28 ms |
212 KB |
answer = YES |
17 |
Correct |
0 ms |
212 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
300 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 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
answer = YES |
2 |
Correct |
0 ms |
212 KB |
answer = YES |
3 |
Correct |
1 ms |
212 KB |
answer = YES |
4 |
Correct |
0 ms |
212 KB |
answer = NO |
5 |
Correct |
27 ms |
632 KB |
answer = YES |
6 |
Correct |
0 ms |
300 KB |
answer = YES |
7 |
Correct |
1 ms |
212 KB |
answer = YES |
8 |
Correct |
2 ms |
212 KB |
answer = YES |
9 |
Correct |
2 ms |
212 KB |
answer = NO |
10 |
Correct |
2 ms |
304 KB |
answer = YES |
11 |
Correct |
1 ms |
212 KB |
answer = YES |
12 |
Correct |
2 ms |
300 KB |
answer = NO |
13 |
Correct |
23 ms |
212 KB |
answer = YES |
14 |
Correct |
25 ms |
300 KB |
answer = YES |
15 |
Correct |
25 ms |
292 KB |
answer = YES |
16 |
Correct |
28 ms |
212 KB |
answer = YES |
17 |
Correct |
0 ms |
212 KB |
answer = YES |
18 |
Correct |
0 ms |
212 KB |
answer = YES |
19 |
Correct |
1 ms |
212 KB |
answer = YES |
20 |
Correct |
1 ms |
300 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 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
25 |
Halted |
0 ms |
0 KB |
- |