#include "libmean.h"
#include <bits/stdc++.h>
using namespace std;
int ans[100], c[5];
int main() {
int n = Init();
fill(ans, ans + n, -1);
queue<int> cand;
for (int i = 1; i <= n; i++) cand.push(i);
while (cand.size() > 4) {
for (int i = 0; i < 5; i++) {
c[i] = cand.front();
cand.pop();
}
map<int, vector<int>> occ;
occ[Meandian(c[0], c[1], c[2], c[3])].push_back(c[4]);
occ[Meandian(c[0], c[1], c[2], c[4])].push_back(c[3]);
occ[Meandian(c[0], c[1], c[3], c[4])].push_back(c[2]);
occ[Meandian(c[0], c[2], c[3], c[4])].push_back(c[1]);
occ[Meandian(c[1], c[2], c[3], c[4])].push_back(c[0]);
int found, val = 0;
for (pair<int, vector<int>> i : occ) {
if (i.second.size() == 1) {
found = i.second[0];
val -= i.first;
} else val += i.first;
}
ans[found - 1] = val;
for (int i = 0; i < 5; i++) if (c[i] != found) cand.push(c[i]);
}
Solution(ans);
}
Compilation message
meandian.cpp: In function 'int main()':
meandian.cpp:30:19: warning: 'found' may be used uninitialized in this function [-Wmaybe-uninitialized]
30 | ans[found - 1] = val;
| ~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
256 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
256 KB |
Output is correct |