CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Summat
Sender:rasastusni
Submission time:2020-09-26 23:07:04 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#20.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#40.01 s1, 2, 3details
#50.01 s1, 2, 3details
#60.01 s2, 3details
#70.01 s2, 3details
#80.01 s2, 3details
#90.01 s2, 3details
#100.01 s2, 3details
#110.01 s3details
#120.01 s3details
#130.37 s3details
#14--3details
#150.01 s3details

Code

#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int n;
int b[50];
int M[50][100];
int c = 0;
set<int> pivoted;
int find_pivot(int i) {
for (int a = 0; a < c; ++a) {
if (M[a][i] != 0 && pivoted.find(a) == pivoted.end()) {
if (M[a][i] != 1) {
int bs = M[a][i];
for (int k = 0; k < n; ++k) {
M[a][k] /= bs;
}
b[a] /= bs;
}
//cout << i << endl;
//for (int k = 0; k < n; ++k) {
// cout << M[a][k] << " ";
//}
//cout << endl;
pivoted.insert(a);
return a;
}
}
return -1;
}
void gauss() {
for (int i = 0; i < n; ++i) {
//for (int a = 0; a < c; ++a) {
//for (int k = 0; k < n; ++k) {
// cout << M[a][k] << " ";
//}
//cout << b[a] << endl;
//}
int pivot = find_pivot(i);
//cout << pivot << endl;
if (pivot == -1) continue;
for (int a = 0; a < c; ++a) {
if (a != pivot && M[a][i] != 0) {
int bs = M[a][i];
for (int k = 0; k < n; ++k) {
M[a][k] -= bs * M[pivot][k];
}
b[a] -= bs * b[pivot];
}
}
}
}
int main()
{
cin >> n;
for (int i = 0; i < n*(n-1)/2; ++i) {
cin >> b[i];
}
for (int i = 0; i < n; ++i) {
for (int a = i + 1; a < n; ++a) {
M[c][i] = 1;
M[c][a] = 1;
++c;
}
}
if (c != n*(n-1)/2) cout << "NOPE" << endl;
gauss();
for (auto x : pivoted) {
cout << b[x];
if (x != *pivoted.rbegin()) cout << " ";
}
cout << endl;
//for (int i = 0; i < c; ++i) {
// for (int k = 0; k < n; ++k) {
// cout << M[i][k];
// }
// cout << endl;
// cout << b[i] << endl;
//}
}

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:

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 4

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:

input
5
2 3 3 6 6 6 6 7 7 10

correct output
1 1 2 5 5 

user output
0 2 3 3 6

Test 5

Group: 1, 2, 3

Verdict:

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 3

Test 6

Group: 2, 3

Verdict:

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
2

Test 7

Group: 2, 3

Verdict:

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
1350 -1352 -1346 -1358 -1335 -...

Test 8

Group: 2, 3

Verdict:

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
(empty)

Test 9

Group: 2, 3

Verdict:

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
(empty)

Test 10

Group: 2, 3

Verdict:

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
(empty)

Test 11

Group: 3

Verdict:

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
2

Test 12

Group: 3

Verdict:

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
1350 -1352 -1346 -1358 -1335 -...

Test 13

Group: 3

Verdict:

input
100
502824619 505239810 505668108 ...

correct output
1 502824618 505239809 50566810...

user output
(empty)

Test 14

Group: 3

Verdict:

input
100
17871832 41618648 51611938 538...

correct output
3939271 13932561 37679377 4989...

user output
(empty)

Test 15

Group: 3

Verdict:

input
100
70588435 115481965 116040218 1...

correct output
5902586 64685849 109579379 110...

user output
(empty)