Submission #925319

# Submission time Handle Problem Language Result Execution time Memory
925319 2024-02-11T11:53:35 Z 8pete8 Toys (CEOI18_toy) C++17
100 / 100
986 ms 234192 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<cassert>
#include<limits.h>
#include<cmath>
#include<set>
#include<numeric> //gcd(a,b)
#include<algorithm>
#include<bitset> 
#include<stack>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define pppiiii pair<pii,pii>
#define ppii pair<int,pii>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
#define int long long
const int mod=1e9+7,mxn=2e5+5,lg=30,inf=1e18,minf=-1e18,Mxn=100000,root=700;
void setIO(string name){		
	ios_base::sync_with_stdio(0); cin.tie(0);		
	freopen((name+".in").c_str(),"r",stdin);		
	freopen((name+".out").c_str(),"w",stdout);	
}	
int n;
vector<int>getdiv(int a){
	vector<int>ans;
	for(int i=1;i*i<=a;i++)if(a%i==0)ans.pb(i),ans.pb(a/i);
	sort(all(ans));
	ans.erase(unique(all(ans)),ans.end());
	return ans;
}
unordered_map<int,int>pos;
vector<int>ans[mxn+10];
int32_t main(){
	//setIO("redistricting");
	fastio
	int n;cin>>n;
	vector<int>div=getdiv(n);
	sort(all(div));
	for(int i=0;i<div.size();i++)pos[div[i]]=i;
	ans[0].pb(0);
	for(int i=0;i<div.size();i++){
		vector<int>v=getdiv(div[i]);
		for(auto k:v)for(auto j:ans[pos[div[i]/k]])ans[i].pb(j+k-1);
		sort(all(ans[i]));
		ans[i].erase(unique(all(ans[i])),ans[i].end());
	}
	int k=div.size()-1;
	cout<<ans[k].size()<<'\n';
	for(auto i:ans[k])cout<<i<<" ";
}

Compilation message

toy.cpp: In function 'int32_t main()':
toy.cpp:56:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for(int i=0;i<div.size();i++)pos[div[i]]=i;
      |              ~^~~~~~~~~~~
toy.cpp:58:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |  for(int i=0;i<div.size();i++){
      |              ~^~~~~~~~~~~
toy.cpp: In function 'void setIO(std::string)':
toy.cpp:37:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:38:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 5212 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 1 ms 4960 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 1 ms 4960 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 5212 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 1 ms 4960 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 1 ms 4960 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 5212 KB Output is correct
27 Correct 1 ms 5212 KB Output is correct
28 Correct 1 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 2 ms 5208 KB Output is correct
32 Correct 2 ms 5212 KB Output is correct
33 Correct 2 ms 5212 KB Output is correct
34 Correct 2 ms 5208 KB Output is correct
35 Correct 2 ms 4956 KB Output is correct
36 Correct 1 ms 4956 KB Output is correct
37 Correct 2 ms 4956 KB Output is correct
38 Correct 1 ms 4956 KB Output is correct
39 Correct 1 ms 4956 KB Output is correct
40 Correct 2 ms 4956 KB Output is correct
41 Correct 1 ms 4956 KB Output is correct
42 Correct 1 ms 5156 KB Output is correct
43 Correct 1 ms 4956 KB Output is correct
44 Correct 1 ms 4956 KB Output is correct
45 Correct 1 ms 4956 KB Output is correct
46 Correct 1 ms 4956 KB Output is correct
47 Correct 1 ms 4960 KB Output is correct
48 Correct 1 ms 4964 KB Output is correct
49 Correct 2 ms 4964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 5212 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 1 ms 4960 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 1 ms 4960 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 5212 KB Output is correct
27 Correct 1 ms 5212 KB Output is correct
28 Correct 1 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 2 ms 5208 KB Output is correct
32 Correct 2 ms 5212 KB Output is correct
33 Correct 2 ms 5212 KB Output is correct
34 Correct 2 ms 5208 KB Output is correct
35 Correct 2 ms 4956 KB Output is correct
36 Correct 1 ms 4956 KB Output is correct
37 Correct 2 ms 4956 KB Output is correct
38 Correct 1 ms 4956 KB Output is correct
39 Correct 1 ms 4956 KB Output is correct
40 Correct 2 ms 4956 KB Output is correct
41 Correct 1 ms 4956 KB Output is correct
42 Correct 1 ms 5156 KB Output is correct
43 Correct 1 ms 4956 KB Output is correct
44 Correct 1 ms 4956 KB Output is correct
45 Correct 1 ms 4956 KB Output is correct
46 Correct 1 ms 4956 KB Output is correct
47 Correct 1 ms 4960 KB Output is correct
48 Correct 1 ms 4964 KB Output is correct
49 Correct 2 ms 4964 KB Output is correct
50 Correct 3 ms 5472 KB Output is correct
51 Correct 2 ms 5480 KB Output is correct
52 Correct 2 ms 5468 KB Output is correct
53 Correct 2 ms 5468 KB Output is correct
54 Correct 2 ms 5212 KB Output is correct
55 Correct 4 ms 5644 KB Output is correct
56 Correct 3 ms 5468 KB Output is correct
57 Correct 3 ms 5468 KB Output is correct
58 Correct 1 ms 4956 KB Output is correct
59 Correct 1 ms 4956 KB Output is correct
60 Correct 2 ms 4956 KB Output is correct
61 Correct 2 ms 5212 KB Output is correct
62 Correct 2 ms 5208 KB Output is correct
63 Correct 2 ms 5212 KB Output is correct
64 Correct 2 ms 4956 KB Output is correct
65 Correct 2 ms 5212 KB Output is correct
66 Correct 2 ms 4956 KB Output is correct
67 Correct 1 ms 5152 KB Output is correct
68 Correct 1 ms 4956 KB Output is correct
69 Correct 1 ms 4956 KB Output is correct
70 Correct 2 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 5212 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 1 ms 4960 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 1 ms 4960 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 5212 KB Output is correct
27 Correct 1 ms 5212 KB Output is correct
28 Correct 1 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 2 ms 5208 KB Output is correct
32 Correct 2 ms 5212 KB Output is correct
33 Correct 2 ms 5212 KB Output is correct
34 Correct 2 ms 5208 KB Output is correct
35 Correct 2 ms 4956 KB Output is correct
36 Correct 1 ms 4956 KB Output is correct
37 Correct 2 ms 4956 KB Output is correct
38 Correct 1 ms 4956 KB Output is correct
39 Correct 1 ms 4956 KB Output is correct
40 Correct 2 ms 4956 KB Output is correct
41 Correct 1 ms 4956 KB Output is correct
42 Correct 1 ms 5156 KB Output is correct
43 Correct 1 ms 4956 KB Output is correct
44 Correct 1 ms 4956 KB Output is correct
45 Correct 1 ms 4956 KB Output is correct
46 Correct 1 ms 4956 KB Output is correct
47 Correct 1 ms 4960 KB Output is correct
48 Correct 1 ms 4964 KB Output is correct
49 Correct 2 ms 4964 KB Output is correct
50 Correct 3 ms 5472 KB Output is correct
51 Correct 2 ms 5480 KB Output is correct
52 Correct 2 ms 5468 KB Output is correct
53 Correct 2 ms 5468 KB Output is correct
54 Correct 2 ms 5212 KB Output is correct
55 Correct 4 ms 5644 KB Output is correct
56 Correct 3 ms 5468 KB Output is correct
57 Correct 3 ms 5468 KB Output is correct
58 Correct 1 ms 4956 KB Output is correct
59 Correct 1 ms 4956 KB Output is correct
60 Correct 2 ms 4956 KB Output is correct
61 Correct 2 ms 5212 KB Output is correct
62 Correct 2 ms 5208 KB Output is correct
63 Correct 2 ms 5212 KB Output is correct
64 Correct 2 ms 4956 KB Output is correct
65 Correct 2 ms 5212 KB Output is correct
66 Correct 2 ms 4956 KB Output is correct
67 Correct 1 ms 5152 KB Output is correct
68 Correct 1 ms 4956 KB Output is correct
69 Correct 1 ms 4956 KB Output is correct
70 Correct 2 ms 5212 KB Output is correct
71 Correct 150 ms 39216 KB Output is correct
72 Correct 108 ms 31536 KB Output is correct
73 Correct 143 ms 39044 KB Output is correct
74 Correct 79 ms 22728 KB Output is correct
75 Correct 93 ms 25656 KB Output is correct
76 Correct 237 ms 57224 KB Output is correct
77 Correct 207 ms 53436 KB Output is correct
78 Correct 186 ms 46468 KB Output is correct
79 Correct 189 ms 47908 KB Output is correct
80 Correct 2 ms 4952 KB Output is correct
81 Correct 1 ms 4956 KB Output is correct
82 Correct 3 ms 5468 KB Output is correct
83 Correct 22 ms 9940 KB Output is correct
84 Correct 28 ms 11732 KB Output is correct
85 Correct 7 ms 6492 KB Output is correct
86 Correct 2 ms 4956 KB Output is correct
87 Correct 30 ms 11896 KB Output is correct
88 Correct 2 ms 4952 KB Output is correct
89 Correct 2 ms 4956 KB Output is correct
90 Correct 2 ms 4956 KB Output is correct
91 Correct 10 ms 6784 KB Output is correct
92 Correct 37 ms 12660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4952 KB Output is correct
4 Correct 1 ms 4952 KB Output is correct
5 Correct 3 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4952 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 2 ms 4956 KB Output is correct
19 Correct 2 ms 5212 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 1 ms 4960 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 1 ms 4960 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 2 ms 5212 KB Output is correct
27 Correct 1 ms 5212 KB Output is correct
28 Correct 1 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 2 ms 5208 KB Output is correct
32 Correct 2 ms 5212 KB Output is correct
33 Correct 2 ms 5212 KB Output is correct
34 Correct 2 ms 5208 KB Output is correct
35 Correct 2 ms 4956 KB Output is correct
36 Correct 1 ms 4956 KB Output is correct
37 Correct 2 ms 4956 KB Output is correct
38 Correct 1 ms 4956 KB Output is correct
39 Correct 1 ms 4956 KB Output is correct
40 Correct 2 ms 4956 KB Output is correct
41 Correct 1 ms 4956 KB Output is correct
42 Correct 1 ms 5156 KB Output is correct
43 Correct 1 ms 4956 KB Output is correct
44 Correct 1 ms 4956 KB Output is correct
45 Correct 1 ms 4956 KB Output is correct
46 Correct 1 ms 4956 KB Output is correct
47 Correct 1 ms 4960 KB Output is correct
48 Correct 1 ms 4964 KB Output is correct
49 Correct 2 ms 4964 KB Output is correct
50 Correct 3 ms 5472 KB Output is correct
51 Correct 2 ms 5480 KB Output is correct
52 Correct 2 ms 5468 KB Output is correct
53 Correct 2 ms 5468 KB Output is correct
54 Correct 2 ms 5212 KB Output is correct
55 Correct 4 ms 5644 KB Output is correct
56 Correct 3 ms 5468 KB Output is correct
57 Correct 3 ms 5468 KB Output is correct
58 Correct 1 ms 4956 KB Output is correct
59 Correct 1 ms 4956 KB Output is correct
60 Correct 2 ms 4956 KB Output is correct
61 Correct 2 ms 5212 KB Output is correct
62 Correct 2 ms 5208 KB Output is correct
63 Correct 2 ms 5212 KB Output is correct
64 Correct 2 ms 4956 KB Output is correct
65 Correct 2 ms 5212 KB Output is correct
66 Correct 2 ms 4956 KB Output is correct
67 Correct 1 ms 5152 KB Output is correct
68 Correct 1 ms 4956 KB Output is correct
69 Correct 1 ms 4956 KB Output is correct
70 Correct 2 ms 5212 KB Output is correct
71 Correct 150 ms 39216 KB Output is correct
72 Correct 108 ms 31536 KB Output is correct
73 Correct 143 ms 39044 KB Output is correct
74 Correct 79 ms 22728 KB Output is correct
75 Correct 93 ms 25656 KB Output is correct
76 Correct 237 ms 57224 KB Output is correct
77 Correct 207 ms 53436 KB Output is correct
78 Correct 186 ms 46468 KB Output is correct
79 Correct 189 ms 47908 KB Output is correct
80 Correct 2 ms 4952 KB Output is correct
81 Correct 1 ms 4956 KB Output is correct
82 Correct 3 ms 5468 KB Output is correct
83 Correct 22 ms 9940 KB Output is correct
84 Correct 28 ms 11732 KB Output is correct
85 Correct 7 ms 6492 KB Output is correct
86 Correct 2 ms 4956 KB Output is correct
87 Correct 30 ms 11896 KB Output is correct
88 Correct 2 ms 4952 KB Output is correct
89 Correct 2 ms 4956 KB Output is correct
90 Correct 2 ms 4956 KB Output is correct
91 Correct 10 ms 6784 KB Output is correct
92 Correct 37 ms 12660 KB Output is correct
93 Correct 829 ms 187212 KB Output is correct
94 Correct 467 ms 105360 KB Output is correct
95 Correct 515 ms 131828 KB Output is correct
96 Correct 477 ms 110368 KB Output is correct
97 Correct 426 ms 106244 KB Output is correct
98 Correct 916 ms 215796 KB Output is correct
99 Correct 986 ms 234192 KB Output is correct
100 Correct 912 ms 213412 KB Output is correct
101 Correct 868 ms 204596 KB Output is correct
102 Correct 779 ms 179324 KB Output is correct
103 Correct 598 ms 149248 KB Output is correct
104 Correct 2 ms 4952 KB Output is correct
105 Correct 2 ms 4956 KB Output is correct
106 Correct 4 ms 5724 KB Output is correct
107 Correct 68 ms 20216 KB Output is correct
108 Correct 175 ms 43812 KB Output is correct
109 Correct 20 ms 8596 KB Output is correct
110 Correct 4 ms 4956 KB Output is correct
111 Correct 87 ms 24344 KB Output is correct
112 Correct 2 ms 4952 KB Output is correct
113 Correct 3 ms 5156 KB Output is correct
114 Correct 5 ms 5724 KB Output is correct
115 Correct 2 ms 4956 KB Output is correct
116 Correct 8 ms 6360 KB Output is correct
117 Correct 163 ms 39584 KB Output is correct