Submission #255691

# Submission time Handle Problem Language Result Execution time Memory
255691 2020-08-01T14:39:09 Z cfalas Toys (CEOI18_toy) C++14
100 / 100
4019 ms 86928 KB
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID (l+r)/2
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

#define EPS 1e-6

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//typedef cc_hash_table<int, set<int>, hash<set<int> >> ht;
//map<int, set<int>> ans;
unordered_map<int, set<int> > ans;
int cnt=0;
int desc(ll n, set<int> cdiv=set<int>()){
    if(ans.count(n)!=0) return ans[n].size();
	//cout<<cdiv.size()<<endl;
	if(cdiv.empty()){
		cnt++;
		for(int i=2;i*i<=n;i++){
			if(n%i==0) cdiv.insert(i);
		}
	}
	else{
		auto i = cdiv.begin();
		while(i!=cdiv.end()){
			//cout<<n<<" "<<*i<<endl;
			if(*(i)==0 || n%(*(i))!=0 || n==*i) i = cdiv.erase(i);
			else i++;
		}
		//cout<<"-----"<<endl;

	}
	for(auto i : cdiv){
        if(n%i) continue;
        desc(n/i, cdiv);
		for(auto q : ans[n/i])
			ans[n].insert(q+i-1);
    }
    ans[n].insert(n-1);
    return ans[n].size();
}

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    ll n;
    cin>>n;
    cout<<desc(n)<<endl;
    //for(int i=1;i<=10;i++) cout<<desc(i)<<" ";
    for(auto v : ans[n]) cout<<v<<" ";
	assert(cnt==1);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 0 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 1 ms 384 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 0 ms 256 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 0 ms 256 KB Output is correct
45 Correct 1 ms 384 KB Output is correct
46 Correct 0 ms 256 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 0 ms 256 KB Output is correct
49 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 0 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 1 ms 384 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 0 ms 256 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 0 ms 256 KB Output is correct
45 Correct 1 ms 384 KB Output is correct
46 Correct 0 ms 256 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 0 ms 256 KB Output is correct
49 Correct 1 ms 384 KB Output is correct
50 Correct 6 ms 640 KB Output is correct
51 Correct 5 ms 512 KB Output is correct
52 Correct 5 ms 640 KB Output is correct
53 Correct 5 ms 512 KB Output is correct
54 Correct 3 ms 512 KB Output is correct
55 Correct 8 ms 640 KB Output is correct
56 Correct 7 ms 640 KB Output is correct
57 Correct 7 ms 640 KB Output is correct
58 Correct 1 ms 256 KB Output is correct
59 Correct 0 ms 256 KB Output is correct
60 Correct 1 ms 384 KB Output is correct
61 Correct 3 ms 512 KB Output is correct
62 Correct 2 ms 384 KB Output is correct
63 Correct 1 ms 384 KB Output is correct
64 Correct 1 ms 384 KB Output is correct
65 Correct 3 ms 512 KB Output is correct
66 Correct 0 ms 256 KB Output is correct
67 Correct 1 ms 256 KB Output is correct
68 Correct 1 ms 256 KB Output is correct
69 Correct 1 ms 384 KB Output is correct
70 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 0 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 1 ms 384 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 0 ms 256 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 0 ms 256 KB Output is correct
45 Correct 1 ms 384 KB Output is correct
46 Correct 0 ms 256 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 0 ms 256 KB Output is correct
49 Correct 1 ms 384 KB Output is correct
50 Correct 6 ms 640 KB Output is correct
51 Correct 5 ms 512 KB Output is correct
52 Correct 5 ms 640 KB Output is correct
53 Correct 5 ms 512 KB Output is correct
54 Correct 3 ms 512 KB Output is correct
55 Correct 8 ms 640 KB Output is correct
56 Correct 7 ms 640 KB Output is correct
57 Correct 7 ms 640 KB Output is correct
58 Correct 1 ms 256 KB Output is correct
59 Correct 0 ms 256 KB Output is correct
60 Correct 1 ms 384 KB Output is correct
61 Correct 3 ms 512 KB Output is correct
62 Correct 2 ms 384 KB Output is correct
63 Correct 1 ms 384 KB Output is correct
64 Correct 1 ms 384 KB Output is correct
65 Correct 3 ms 512 KB Output is correct
66 Correct 0 ms 256 KB Output is correct
67 Correct 1 ms 256 KB Output is correct
68 Correct 1 ms 256 KB Output is correct
69 Correct 1 ms 384 KB Output is correct
70 Correct 3 ms 384 KB Output is correct
71 Correct 676 ms 18704 KB Output is correct
72 Correct 451 ms 14164 KB Output is correct
73 Correct 611 ms 16760 KB Output is correct
74 Correct 334 ms 11128 KB Output is correct
75 Correct 389 ms 12024 KB Output is correct
76 Correct 943 ms 24972 KB Output is correct
77 Correct 793 ms 22056 KB Output is correct
78 Correct 726 ms 20892 KB Output is correct
79 Correct 675 ms 20036 KB Output is correct
80 Correct 1 ms 256 KB Output is correct
81 Correct 1 ms 256 KB Output is correct
82 Correct 4 ms 640 KB Output is correct
83 Correct 61 ms 3576 KB Output is correct
84 Correct 86 ms 4344 KB Output is correct
85 Correct 16 ms 1536 KB Output is correct
86 Correct 1 ms 384 KB Output is correct
87 Correct 91 ms 4984 KB Output is correct
88 Correct 1 ms 256 KB Output is correct
89 Correct 1 ms 256 KB Output is correct
90 Correct 1 ms 384 KB Output is correct
91 Correct 31 ms 2168 KB Output is correct
92 Correct 165 ms 6520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 0 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 1 ms 256 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 0 ms 256 KB Output is correct
35 Correct 0 ms 256 KB Output is correct
36 Correct 0 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 1 ms 384 KB Output is correct
41 Correct 1 ms 256 KB Output is correct
42 Correct 0 ms 256 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 0 ms 256 KB Output is correct
45 Correct 1 ms 384 KB Output is correct
46 Correct 0 ms 256 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 0 ms 256 KB Output is correct
49 Correct 1 ms 384 KB Output is correct
50 Correct 6 ms 640 KB Output is correct
51 Correct 5 ms 512 KB Output is correct
52 Correct 5 ms 640 KB Output is correct
53 Correct 5 ms 512 KB Output is correct
54 Correct 3 ms 512 KB Output is correct
55 Correct 8 ms 640 KB Output is correct
56 Correct 7 ms 640 KB Output is correct
57 Correct 7 ms 640 KB Output is correct
58 Correct 1 ms 256 KB Output is correct
59 Correct 0 ms 256 KB Output is correct
60 Correct 1 ms 384 KB Output is correct
61 Correct 3 ms 512 KB Output is correct
62 Correct 2 ms 384 KB Output is correct
63 Correct 1 ms 384 KB Output is correct
64 Correct 1 ms 384 KB Output is correct
65 Correct 3 ms 512 KB Output is correct
66 Correct 0 ms 256 KB Output is correct
67 Correct 1 ms 256 KB Output is correct
68 Correct 1 ms 256 KB Output is correct
69 Correct 1 ms 384 KB Output is correct
70 Correct 3 ms 384 KB Output is correct
71 Correct 676 ms 18704 KB Output is correct
72 Correct 451 ms 14164 KB Output is correct
73 Correct 611 ms 16760 KB Output is correct
74 Correct 334 ms 11128 KB Output is correct
75 Correct 389 ms 12024 KB Output is correct
76 Correct 943 ms 24972 KB Output is correct
77 Correct 793 ms 22056 KB Output is correct
78 Correct 726 ms 20892 KB Output is correct
79 Correct 675 ms 20036 KB Output is correct
80 Correct 1 ms 256 KB Output is correct
81 Correct 1 ms 256 KB Output is correct
82 Correct 4 ms 640 KB Output is correct
83 Correct 61 ms 3576 KB Output is correct
84 Correct 86 ms 4344 KB Output is correct
85 Correct 16 ms 1536 KB Output is correct
86 Correct 1 ms 384 KB Output is correct
87 Correct 91 ms 4984 KB Output is correct
88 Correct 1 ms 256 KB Output is correct
89 Correct 1 ms 256 KB Output is correct
90 Correct 1 ms 384 KB Output is correct
91 Correct 31 ms 2168 KB Output is correct
92 Correct 165 ms 6520 KB Output is correct
93 Correct 3349 ms 77404 KB Output is correct
94 Correct 2013 ms 52260 KB Output is correct
95 Correct 2257 ms 54812 KB Output is correct
96 Correct 2013 ms 49144 KB Output is correct
97 Correct 1748 ms 44668 KB Output is correct
98 Correct 3619 ms 85432 KB Output is correct
99 Correct 4019 ms 86928 KB Output is correct
100 Correct 3571 ms 83540 KB Output is correct
101 Correct 3179 ms 77248 KB Output is correct
102 Correct 2830 ms 69728 KB Output is correct
103 Correct 2383 ms 62408 KB Output is correct
104 Correct 1 ms 256 KB Output is correct
105 Correct 1 ms 256 KB Output is correct
106 Correct 7 ms 896 KB Output is correct
107 Correct 195 ms 9592 KB Output is correct
108 Correct 536 ms 20472 KB Output is correct
109 Correct 42 ms 3192 KB Output is correct
110 Correct 1 ms 256 KB Output is correct
111 Correct 268 ms 12152 KB Output is correct
112 Correct 1 ms 256 KB Output is correct
113 Correct 1 ms 256 KB Output is correct
114 Correct 10 ms 896 KB Output is correct
115 Correct 1 ms 256 KB Output is correct
116 Correct 19 ms 1664 KB Output is correct
117 Correct 786 ms 24568 KB Output is correct