Task: | Summat |
Sender: | Metabolix |
Submission time: | 2020-09-26 06:11:25 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 32 |
#3 | ACCEPTED | 56 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#5 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#6 | ACCEPTED | 0.01 s | 2, 3 | details |
#7 | ACCEPTED | 0.01 s | 2, 3 | details |
#8 | ACCEPTED | 0.01 s | 2, 3 | details |
#9 | ACCEPTED | 0.01 s | 2, 3 | details |
#10 | ACCEPTED | 0.01 s | 2, 3 | details |
#11 | ACCEPTED | 0.01 s | 3 | details |
#12 | ACCEPTED | 0.01 s | 3 | details |
#13 | ACCEPTED | 0.01 s | 3 | details |
#14 | ACCEPTED | 0.01 s | 3 | details |
#15 | ACCEPTED | 0.01 s | 3 | details |
Compiler report
input/code.cpp: In function 'bool ratkaise(int, int, std::vector<int>&, std::unordered_map<int, int>&)': input/code.cpp:14:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < luvut.size(); ++i) { ~~^~~~~~~~~~~~~~ input/code.cpp: In function 'int main()': input/code.cpp:44:6: warning: unused variable 'luvut_keskiarvo' [-Wunused-variable] int luvut_keskiarvo = luvut_yhteensa / n; ^~~~~~~~~~~~~~~
Code
#include <iostream> #include <vector> #include <set> #include <unordered_map> #include <algorithm> bool ratkaise(int a, int n, std::vector<int>& summat_v, std::unordered_map<int, int>& summat_m) { std::vector<int> luvut {a}; std::unordered_map<int, int> tarjolla; for (int summa: summat_v) { int maara = summat_m[summa]; while (tarjolla[summa] < maara) { int b = summa - luvut[0]; for (int i = 0; i < luvut.size(); ++i) { int c = b + luvut[i]; tarjolla[c] += 1; if (tarjolla[c] > summat_m[c]) { return false; } } luvut.push_back(b); } } for (int luku: luvut) { std::cout << luku << ' '; } std::cout << '\n'; return true; } int main() { int n; std::cin >> n; std::vector<int> summat(n * (n-1) / 2); std::set<int> summat_s; std::unordered_map<int, int> summat_m; long summat_yhteensa = 0; for (auto& k: summat) { std::cin >> k; summat_m[k] += 1; summat_yhteensa += k; } long luvut_yhteensa = summat_yhteensa / (n-1); int luvut_keskiarvo = luvut_yhteensa / n; for (auto s: summat_m) { summat_s.insert(s.first); } std::vector<int> summat_v(summat_s.begin(), summat_s.end()); long ab = summat_v[0]; long ac = summat_v[summat_m[ab] > 1 ? 0 : 1]; for (long bc: summat_v) { int aa = ab + ac - bc; int a = aa / 2; if ((aa & 1) == 0 && ratkaise(a, n, summat_v, summat_m)) { break; } } }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 2 2 2 2 2 2 2 2 2 2 |
correct output |
---|
1 1 1 1 1 |
user output |
---|
1 1 1 1 1 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 3 4 5 5 6 6 7 7 8 9 |
correct output |
---|
1 2 3 4 5 |
user output |
---|
1 2 3 4 5 |
Test 3
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 5 6 6 6 9 9 9 10 10 10 |
correct output |
---|
1 4 5 5 5 |
user output |
---|
1 4 5 5 5 |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 2 3 3 6 6 6 6 7 7 10 |
correct output |
---|
1 1 2 5 5 |
user output |
---|
1 1 2 5 5 |
Test 5
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
5 4 5 5 5 5 6 6 6 7 7 |
correct output |
---|
2 2 3 3 4 |
user output |
---|
2 2 3 3 4 |
Test 6
Group: 2, 3
Verdict: ACCEPTED
input |
---|
20 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
Test 7
Group: 2, 3
Verdict: ACCEPTED
input |
---|
20 3 4 5 5 6 6 7 7 7 8 8 8 9 9 9 ... |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
Test 8
Group: 2, 3
Verdict: ACCEPTED
input |
---|
20 52 55 55 57 62 62 63 64 66 71 ... |
correct output |
---|
1 51 54 54 56 61 61 62 63 65 7... |
user output |
---|
1 51 54 54 56 61 61 62 63 65 7... |
Test 9
Group: 2, 3
Verdict: ACCEPTED
input |
---|
20 25 30 31 32 36 39 40 41 45 45 ... |
correct output |
---|
8 17 22 23 24 28 43 50 53 55 6... |
user output |
---|
8 17 22 23 24 28 43 50 53 55 6... |
Test 10
Group: 2, 3
Verdict: ACCEPTED
input |
---|
20 9 10 14 17 17 20 21 22 24 25 2... |
correct output |
---|
1 8 9 13 16 19 30 32 38 40 43 ... |
user output |
---|
1 8 9 13 16 19 30 32 38 40 43 ... |
Test 11
Group: 3
Verdict: ACCEPTED
input |
---|
100 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ... |
correct output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... |
user output |
---|
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... Truncated |
Test 12
Group: 3
Verdict: ACCEPTED
input |
---|
100 3 4 5 5 6 6 7 7 7 8 8 8 9 9 9 ... |
correct output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
user output |
---|
1 2 3 4 5 6 7 8 9 10 11 12 13 ... Truncated |
Test 13
Group: 3
Verdict: ACCEPTED
input |
---|
100 502824619 505239810 505668108 ... |
correct output |
---|
1 502824618 505239809 50566810... |
user output |
---|
1 502824618 505239809 50566810... Truncated |
Test 14
Group: 3
Verdict: ACCEPTED
input |
---|
100 17871832 41618648 51611938 538... |
correct output |
---|
3939271 13932561 37679377 4989... |
user output |
---|
3939271 13932561 37679377 4989... Truncated |
Test 15
Group: 3
Verdict: ACCEPTED
input |
---|
100 70588435 115481965 116040218 1... |
correct output |
---|
5902586 64685849 109579379 110... |
user output |
---|
5902586 64685849 109579379 110... Truncated |