CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Planeetat
Sender:jnalanko
Submission time:2020-09-27 02:50:44 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#8ACCEPTED0.01 s1, 2, 3details
#9ACCEPTED0.01 s1, 2, 3details
#100.01 s1, 2, 3details
#110.01 s2, 3details
#120.01 s2, 3details
#130.01 s2, 3details
#140.01 s3details
#150.01 s3details
#160.01 s3details
#170.01 s3details
#180.01 s3details
#190.01 s3details
#200.01 s3details
#210.01 s3details
#220.01 s3details
#230.01 s3details
#240.01 s3details
#250.01 s3details

Code

#include <iostream>
#include <vector>
#include <cassert>
#include <set>
//#include "stdlib_printing.hh"

typedef long long LL;

using namespace std;

LL count_cycles(const vector<LL>& edges, vector<LL>& indegs){
    LL n = edges.size();
    vector<bool> visited(n);
    vector<LL> Q;
    for(LL v = 0; v < n; v++) if(indegs[v] == 0) Q.push_back(v);
    while(!Q.empty()){
        LL v = Q.back(); Q.pop_back();
        if(visited[v]) continue;
        visited[v] = true;
        indegs[edges[v]]--;
        if(indegs[edges[v]] == 0) Q.push_back(edges[v]);
    }
    LL cycles = 0;
    for(LL v = 0; v < n; v++){
        if(visited[v]) continue;
        cycles++;
        while(!visited[v]){
            visited[v] = true;
            v = edges[v];
        }
    }
    return cycles;
}

void brute(LL n){
    vector<LL> edges(n);
    vector<LL> ans(n+1);
    vector<LL> indegs(n,0);

    LL N = 1; for(LL i = 0; i < n; i++) N *= n; // n^n
    for(LL x = 0; x < N; x++){
        // Interpret x as a base-n number
        LL y = x;
        for(LL i = 0; i < n; i++) indegs[i] = 0;
        for(LL v = 0; v < n; v++){
            LL u = y%n;
            edges[v] = u;
            indegs[u]++;
            y /= n;
        }
        LL cycles = count_cycles(edges, indegs);
        ans[cycles]++;
    }
    for(LL i = 1; i <= n; i++) cout << ans[i] << "\n";
}

int main(){
    vector<vector<LL> > ans(10+1);
    ans[0] = {};
    ans[1] = {1};
    ans[2] = {3,1};
    ans[3] = {17,9,1};
    ans[4] = {142,95,18,1};
    ans[5] = {1569,1220,305,30,1};
    ans[6] = {21576, 18694, 5595, 745, 45, 1};
    ans[7] = {355081, 334369, 113974, 18515, 1540, 63, 1};
    ans[8] = {6805296, 6852460, 2581964, 484729, 49840, 2842, 84, 1};
    ans[9] = {148869153, 158479488, 64727522, 13591116, 1632099, 116172, 4830, 108, 1};
    ans[10] = {3660215680, 4085349936, 1783995060, 409987640, 55545735, 4654713, 243390, 7710, 135, 1};
    LL n; cin >> n;
    for(LL k = 0; k < n; k++) cout << ans[n][k] << "\n";
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
1

correct output
1

user output
1

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
2

correct output
3
1

user output
3
1

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
3

correct output
17
9
1

user output
17
9
1

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
4

correct output
142
95
18
1

user output
142
95
18
1

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
5

correct output
1569
1220
305
30
1

user output
1569
1220
305
30
1

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

input
6

correct output
21576
18694
5595
745
45
...

user output
21576
18694
5595
745
45
...

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
7

correct output
355081
334369
113974
18515
1540
...

user output
355081
334369
113974
18515
1540
...

Test 8

Group: 1, 2, 3

Verdict: ACCEPTED

input
8

correct output
6805296
6852460
2581964
484729
49840
...

user output
6805296
6852460
2581964
484729
49840
...

Test 9

Group: 1, 2, 3

Verdict: ACCEPTED

input
9

correct output
148869153
158479488
64727522
13591116
1632099
...

user output
148869153
158479488
64727522
13591116
1632099
...

Test 10

Group: 1, 2, 3

Verdict:

input
10

correct output
660215659
85349908
783995053
409987640
55545735
...

user output
3660215680
4085349936
1783995060
409987640
55545735
...

Test 11

Group: 2, 3

Verdict:

input
20

correct output
8033007
474885151
998010619
720259168
345757330
...

user output
(empty)

Test 12

Group: 2, 3

Verdict:

input
50

correct output
637699856
613177596
194234103
50828885
988168359
...

user output
(empty)

Test 13

Group: 2, 3

Verdict:

input
100

correct output
894456323
406549429
962038245
430640330
61348310
...

user output
(empty)

Test 14

Group: 3

Verdict:

input
666

correct output
189730587
968711879
553374698
53051125
139917248
...

user output
(empty)

Test 15

Group: 3

Verdict:

input
3333

correct output
79235821
455292218
627100211
591681254
695866885
...

user output
(empty)

Test 16

Group: 3

Verdict:

input
4991

correct output
482116496
245260697
151422537
180441123
318466624
...

user output
(empty)

Test 17

Group: 3

Verdict:

input
4992

correct output
141010647
787351178
684701591
872974815
631476284
...

user output
(empty)

Test 18

Group: 3

Verdict:

input
4993

correct output
504034249
588971460
281533415
928250892
416697844
...

user output
(empty)

Test 19

Group: 3

Verdict:

input
4994

correct output
266134603
90079109
544661648
812099750
17249410
...

user output
(empty)

Test 20

Group: 3

Verdict:

input
4995

correct output
833898560
663839791
109127071
321675160
86285359
...

user output
(empty)

Test 21

Group: 3

Verdict:

input
4996

correct output
721158645
167929822
115103278
491345159
114397872
...

user output
(empty)

Test 22

Group: 3

Verdict:

input
4997

correct output
691405606
436947443
82656395
514529009
783319673
...

user output
(empty)

Test 23

Group: 3

Verdict:

input
4998

correct output
829675470
688714502
189351950
956110193
20883331
...

user output
(empty)

Test 24

Group: 3

Verdict:

input
4999

correct output
343936737
47032567
190931571
827280581
160866637
...

user output
(empty)

Test 25

Group: 3

Verdict:

input
5000

correct output
364064601
633559852
352848841
666954216
428009512
...

user output
(empty)