답안 #1035375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035375 2024-07-26T10:02:32 Z ByeWorld Toys (CEOI18_toy) C++14
100 / 100
1464 ms 96084 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
// #define int long long
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> ipii;
const int MAXN = 2e5+15;
const int INF = 1e9+10;
void chmn(int &a, int b){ a = min(a, b); }

int n;
vector <int> vec;
map<int,int> idx;
set <int> s[MAXN];

signed main(){
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    if(n==1){
    	cout << "1\n0\n"; exit(0);
    }
    for(int i=1; i*i<=n; i++){
    	if(n%i == 0){
    		vec.pb(i);
    		if(n != i*i) vec.pb(n/i);
    	}
    }
    sort(vec.begin(), vec.end()); 
    for(int i=0; i<vec.size(); i++) idx[vec[i]] = i;
    s[0].insert(0);
    for(int i=1; i<vec.size(); i++){
    	int x = vec[i];
    	for(int j=1; j*j<=x; j++){
    		// kali j
    		if(x%j != 0) continue;
    		int id = idx[j];
    		for(auto in : s[id]) s[i].insert(in+x/j-1);
    			
    		if(j!=1){
	    		id = idx[x/j];
	    		for(auto in : s[id]) s[i].insert(in+j-1);
	    	}
    	}
    }
    cout << s[vec.size()-1].size() << '\n';
    for(auto in : s[vec.size()-1]) cout << in << ' ';
    cout << '\n';
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0; i<vec.size(); i++) idx[vec[i]] = i;
      |                  ~^~~~~~~~~~~
toy.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=1; i<vec.size(); i++){
      |                  ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9820 KB Output is correct
2 Correct 4 ms 9820 KB Output is correct
3 Correct 4 ms 9820 KB Output is correct
4 Correct 4 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 4 ms 9820 KB Output is correct
7 Correct 4 ms 9632 KB Output is correct
8 Correct 4 ms 9820 KB Output is correct
9 Correct 5 ms 9836 KB Output is correct
10 Correct 5 ms 9816 KB Output is correct
11 Correct 4 ms 9816 KB Output is correct
12 Correct 4 ms 9820 KB Output is correct
13 Correct 4 ms 9820 KB Output is correct
14 Correct 4 ms 9820 KB Output is correct
15 Correct 4 ms 9628 KB Output is correct
16 Correct 4 ms 9816 KB Output is correct
17 Correct 4 ms 9820 KB Output is correct
18 Correct 4 ms 9820 KB Output is correct
19 Correct 4 ms 9820 KB Output is correct
20 Correct 4 ms 9636 KB Output is correct
21 Correct 4 ms 9820 KB Output is correct
22 Correct 4 ms 9820 KB Output is correct
23 Correct 4 ms 9820 KB Output is correct
24 Correct 4 ms 9820 KB Output is correct
25 Correct 4 ms 9816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9820 KB Output is correct
2 Correct 4 ms 9820 KB Output is correct
3 Correct 4 ms 9820 KB Output is correct
4 Correct 4 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 4 ms 9820 KB Output is correct
7 Correct 4 ms 9632 KB Output is correct
8 Correct 4 ms 9820 KB Output is correct
9 Correct 5 ms 9836 KB Output is correct
10 Correct 5 ms 9816 KB Output is correct
11 Correct 4 ms 9816 KB Output is correct
12 Correct 4 ms 9820 KB Output is correct
13 Correct 4 ms 9820 KB Output is correct
14 Correct 4 ms 9820 KB Output is correct
15 Correct 4 ms 9628 KB Output is correct
16 Correct 4 ms 9816 KB Output is correct
17 Correct 4 ms 9820 KB Output is correct
18 Correct 4 ms 9820 KB Output is correct
19 Correct 4 ms 9820 KB Output is correct
20 Correct 4 ms 9636 KB Output is correct
21 Correct 4 ms 9820 KB Output is correct
22 Correct 4 ms 9820 KB Output is correct
23 Correct 4 ms 9820 KB Output is correct
24 Correct 4 ms 9820 KB Output is correct
25 Correct 4 ms 9816 KB Output is correct
26 Correct 5 ms 9820 KB Output is correct
27 Correct 4 ms 9816 KB Output is correct
28 Correct 4 ms 9816 KB Output is correct
29 Correct 5 ms 9820 KB Output is correct
30 Correct 6 ms 9796 KB Output is correct
31 Correct 4 ms 9820 KB Output is correct
32 Correct 5 ms 9820 KB Output is correct
33 Correct 4 ms 9820 KB Output is correct
34 Correct 5 ms 9820 KB Output is correct
35 Correct 4 ms 9820 KB Output is correct
36 Correct 4 ms 9820 KB Output is correct
37 Correct 4 ms 9820 KB Output is correct
38 Correct 4 ms 9832 KB Output is correct
39 Correct 5 ms 9656 KB Output is correct
40 Correct 4 ms 9820 KB Output is correct
41 Correct 6 ms 9820 KB Output is correct
42 Correct 4 ms 9820 KB Output is correct
43 Correct 4 ms 9820 KB Output is correct
44 Correct 4 ms 9820 KB Output is correct
45 Correct 4 ms 9820 KB Output is correct
46 Correct 4 ms 9820 KB Output is correct
47 Correct 4 ms 9820 KB Output is correct
48 Correct 4 ms 9820 KB Output is correct
49 Correct 4 ms 9820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9820 KB Output is correct
2 Correct 4 ms 9820 KB Output is correct
3 Correct 4 ms 9820 KB Output is correct
4 Correct 4 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 4 ms 9820 KB Output is correct
7 Correct 4 ms 9632 KB Output is correct
8 Correct 4 ms 9820 KB Output is correct
9 Correct 5 ms 9836 KB Output is correct
10 Correct 5 ms 9816 KB Output is correct
11 Correct 4 ms 9816 KB Output is correct
12 Correct 4 ms 9820 KB Output is correct
13 Correct 4 ms 9820 KB Output is correct
14 Correct 4 ms 9820 KB Output is correct
15 Correct 4 ms 9628 KB Output is correct
16 Correct 4 ms 9816 KB Output is correct
17 Correct 4 ms 9820 KB Output is correct
18 Correct 4 ms 9820 KB Output is correct
19 Correct 4 ms 9820 KB Output is correct
20 Correct 4 ms 9636 KB Output is correct
21 Correct 4 ms 9820 KB Output is correct
22 Correct 4 ms 9820 KB Output is correct
23 Correct 4 ms 9820 KB Output is correct
24 Correct 4 ms 9820 KB Output is correct
25 Correct 4 ms 9816 KB Output is correct
26 Correct 5 ms 9820 KB Output is correct
27 Correct 4 ms 9816 KB Output is correct
28 Correct 4 ms 9816 KB Output is correct
29 Correct 5 ms 9820 KB Output is correct
30 Correct 6 ms 9796 KB Output is correct
31 Correct 4 ms 9820 KB Output is correct
32 Correct 5 ms 9820 KB Output is correct
33 Correct 4 ms 9820 KB Output is correct
34 Correct 5 ms 9820 KB Output is correct
35 Correct 4 ms 9820 KB Output is correct
36 Correct 4 ms 9820 KB Output is correct
37 Correct 4 ms 9820 KB Output is correct
38 Correct 4 ms 9832 KB Output is correct
39 Correct 5 ms 9656 KB Output is correct
40 Correct 4 ms 9820 KB Output is correct
41 Correct 6 ms 9820 KB Output is correct
42 Correct 4 ms 9820 KB Output is correct
43 Correct 4 ms 9820 KB Output is correct
44 Correct 4 ms 9820 KB Output is correct
45 Correct 4 ms 9820 KB Output is correct
46 Correct 4 ms 9820 KB Output is correct
47 Correct 4 ms 9820 KB Output is correct
48 Correct 4 ms 9820 KB Output is correct
49 Correct 4 ms 9820 KB Output is correct
50 Correct 6 ms 9984 KB Output is correct
51 Correct 6 ms 9948 KB Output is correct
52 Correct 6 ms 10076 KB Output is correct
53 Correct 5 ms 9820 KB Output is correct
54 Correct 5 ms 9812 KB Output is correct
55 Correct 8 ms 10076 KB Output is correct
56 Correct 6 ms 10076 KB Output is correct
57 Correct 7 ms 10072 KB Output is correct
58 Correct 4 ms 9748 KB Output is correct
59 Correct 5 ms 9820 KB Output is correct
60 Correct 4 ms 9820 KB Output is correct
61 Correct 5 ms 9816 KB Output is correct
62 Correct 4 ms 9820 KB Output is correct
63 Correct 4 ms 9652 KB Output is correct
64 Correct 4 ms 9820 KB Output is correct
65 Correct 6 ms 9832 KB Output is correct
66 Correct 4 ms 9820 KB Output is correct
67 Correct 4 ms 9820 KB Output is correct
68 Correct 4 ms 9796 KB Output is correct
69 Correct 4 ms 9820 KB Output is correct
70 Correct 5 ms 9816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9820 KB Output is correct
2 Correct 4 ms 9820 KB Output is correct
3 Correct 4 ms 9820 KB Output is correct
4 Correct 4 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 4 ms 9820 KB Output is correct
7 Correct 4 ms 9632 KB Output is correct
8 Correct 4 ms 9820 KB Output is correct
9 Correct 5 ms 9836 KB Output is correct
10 Correct 5 ms 9816 KB Output is correct
11 Correct 4 ms 9816 KB Output is correct
12 Correct 4 ms 9820 KB Output is correct
13 Correct 4 ms 9820 KB Output is correct
14 Correct 4 ms 9820 KB Output is correct
15 Correct 4 ms 9628 KB Output is correct
16 Correct 4 ms 9816 KB Output is correct
17 Correct 4 ms 9820 KB Output is correct
18 Correct 4 ms 9820 KB Output is correct
19 Correct 4 ms 9820 KB Output is correct
20 Correct 4 ms 9636 KB Output is correct
21 Correct 4 ms 9820 KB Output is correct
22 Correct 4 ms 9820 KB Output is correct
23 Correct 4 ms 9820 KB Output is correct
24 Correct 4 ms 9820 KB Output is correct
25 Correct 4 ms 9816 KB Output is correct
26 Correct 5 ms 9820 KB Output is correct
27 Correct 4 ms 9816 KB Output is correct
28 Correct 4 ms 9816 KB Output is correct
29 Correct 5 ms 9820 KB Output is correct
30 Correct 6 ms 9796 KB Output is correct
31 Correct 4 ms 9820 KB Output is correct
32 Correct 5 ms 9820 KB Output is correct
33 Correct 4 ms 9820 KB Output is correct
34 Correct 5 ms 9820 KB Output is correct
35 Correct 4 ms 9820 KB Output is correct
36 Correct 4 ms 9820 KB Output is correct
37 Correct 4 ms 9820 KB Output is correct
38 Correct 4 ms 9832 KB Output is correct
39 Correct 5 ms 9656 KB Output is correct
40 Correct 4 ms 9820 KB Output is correct
41 Correct 6 ms 9820 KB Output is correct
42 Correct 4 ms 9820 KB Output is correct
43 Correct 4 ms 9820 KB Output is correct
44 Correct 4 ms 9820 KB Output is correct
45 Correct 4 ms 9820 KB Output is correct
46 Correct 4 ms 9820 KB Output is correct
47 Correct 4 ms 9820 KB Output is correct
48 Correct 4 ms 9820 KB Output is correct
49 Correct 4 ms 9820 KB Output is correct
50 Correct 6 ms 9984 KB Output is correct
51 Correct 6 ms 9948 KB Output is correct
52 Correct 6 ms 10076 KB Output is correct
53 Correct 5 ms 9820 KB Output is correct
54 Correct 5 ms 9812 KB Output is correct
55 Correct 8 ms 10076 KB Output is correct
56 Correct 6 ms 10076 KB Output is correct
57 Correct 7 ms 10072 KB Output is correct
58 Correct 4 ms 9748 KB Output is correct
59 Correct 5 ms 9820 KB Output is correct
60 Correct 4 ms 9820 KB Output is correct
61 Correct 5 ms 9816 KB Output is correct
62 Correct 4 ms 9820 KB Output is correct
63 Correct 4 ms 9652 KB Output is correct
64 Correct 4 ms 9820 KB Output is correct
65 Correct 6 ms 9832 KB Output is correct
66 Correct 4 ms 9820 KB Output is correct
67 Correct 4 ms 9820 KB Output is correct
68 Correct 4 ms 9796 KB Output is correct
69 Correct 4 ms 9820 KB Output is correct
70 Correct 5 ms 9816 KB Output is correct
71 Correct 189 ms 27988 KB Output is correct
72 Correct 136 ms 23444 KB Output is correct
73 Correct 178 ms 25940 KB Output is correct
74 Correct 121 ms 20564 KB Output is correct
75 Correct 115 ms 21292 KB Output is correct
76 Correct 300 ms 34132 KB Output is correct
77 Correct 248 ms 31320 KB Output is correct
78 Correct 243 ms 30040 KB Output is correct
79 Correct 221 ms 29268 KB Output is correct
80 Correct 4 ms 9816 KB Output is correct
81 Correct 4 ms 9820 KB Output is correct
82 Correct 5 ms 10076 KB Output is correct
83 Correct 29 ms 12984 KB Output is correct
84 Correct 49 ms 13648 KB Output is correct
85 Correct 12 ms 10840 KB Output is correct
86 Correct 4 ms 9820 KB Output is correct
87 Correct 44 ms 14332 KB Output is correct
88 Correct 4 ms 9820 KB Output is correct
89 Correct 4 ms 9660 KB Output is correct
90 Correct 4 ms 9820 KB Output is correct
91 Correct 14 ms 11624 KB Output is correct
92 Correct 64 ms 15968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9820 KB Output is correct
2 Correct 4 ms 9820 KB Output is correct
3 Correct 4 ms 9820 KB Output is correct
4 Correct 4 ms 9820 KB Output is correct
5 Correct 5 ms 9820 KB Output is correct
6 Correct 4 ms 9820 KB Output is correct
7 Correct 4 ms 9632 KB Output is correct
8 Correct 4 ms 9820 KB Output is correct
9 Correct 5 ms 9836 KB Output is correct
10 Correct 5 ms 9816 KB Output is correct
11 Correct 4 ms 9816 KB Output is correct
12 Correct 4 ms 9820 KB Output is correct
13 Correct 4 ms 9820 KB Output is correct
14 Correct 4 ms 9820 KB Output is correct
15 Correct 4 ms 9628 KB Output is correct
16 Correct 4 ms 9816 KB Output is correct
17 Correct 4 ms 9820 KB Output is correct
18 Correct 4 ms 9820 KB Output is correct
19 Correct 4 ms 9820 KB Output is correct
20 Correct 4 ms 9636 KB Output is correct
21 Correct 4 ms 9820 KB Output is correct
22 Correct 4 ms 9820 KB Output is correct
23 Correct 4 ms 9820 KB Output is correct
24 Correct 4 ms 9820 KB Output is correct
25 Correct 4 ms 9816 KB Output is correct
26 Correct 5 ms 9820 KB Output is correct
27 Correct 4 ms 9816 KB Output is correct
28 Correct 4 ms 9816 KB Output is correct
29 Correct 5 ms 9820 KB Output is correct
30 Correct 6 ms 9796 KB Output is correct
31 Correct 4 ms 9820 KB Output is correct
32 Correct 5 ms 9820 KB Output is correct
33 Correct 4 ms 9820 KB Output is correct
34 Correct 5 ms 9820 KB Output is correct
35 Correct 4 ms 9820 KB Output is correct
36 Correct 4 ms 9820 KB Output is correct
37 Correct 4 ms 9820 KB Output is correct
38 Correct 4 ms 9832 KB Output is correct
39 Correct 5 ms 9656 KB Output is correct
40 Correct 4 ms 9820 KB Output is correct
41 Correct 6 ms 9820 KB Output is correct
42 Correct 4 ms 9820 KB Output is correct
43 Correct 4 ms 9820 KB Output is correct
44 Correct 4 ms 9820 KB Output is correct
45 Correct 4 ms 9820 KB Output is correct
46 Correct 4 ms 9820 KB Output is correct
47 Correct 4 ms 9820 KB Output is correct
48 Correct 4 ms 9820 KB Output is correct
49 Correct 4 ms 9820 KB Output is correct
50 Correct 6 ms 9984 KB Output is correct
51 Correct 6 ms 9948 KB Output is correct
52 Correct 6 ms 10076 KB Output is correct
53 Correct 5 ms 9820 KB Output is correct
54 Correct 5 ms 9812 KB Output is correct
55 Correct 8 ms 10076 KB Output is correct
56 Correct 6 ms 10076 KB Output is correct
57 Correct 7 ms 10072 KB Output is correct
58 Correct 4 ms 9748 KB Output is correct
59 Correct 5 ms 9820 KB Output is correct
60 Correct 4 ms 9820 KB Output is correct
61 Correct 5 ms 9816 KB Output is correct
62 Correct 4 ms 9820 KB Output is correct
63 Correct 4 ms 9652 KB Output is correct
64 Correct 4 ms 9820 KB Output is correct
65 Correct 6 ms 9832 KB Output is correct
66 Correct 4 ms 9820 KB Output is correct
67 Correct 4 ms 9820 KB Output is correct
68 Correct 4 ms 9796 KB Output is correct
69 Correct 4 ms 9820 KB Output is correct
70 Correct 5 ms 9816 KB Output is correct
71 Correct 189 ms 27988 KB Output is correct
72 Correct 136 ms 23444 KB Output is correct
73 Correct 178 ms 25940 KB Output is correct
74 Correct 121 ms 20564 KB Output is correct
75 Correct 115 ms 21292 KB Output is correct
76 Correct 300 ms 34132 KB Output is correct
77 Correct 248 ms 31320 KB Output is correct
78 Correct 243 ms 30040 KB Output is correct
79 Correct 221 ms 29268 KB Output is correct
80 Correct 4 ms 9816 KB Output is correct
81 Correct 4 ms 9820 KB Output is correct
82 Correct 5 ms 10076 KB Output is correct
83 Correct 29 ms 12984 KB Output is correct
84 Correct 49 ms 13648 KB Output is correct
85 Correct 12 ms 10840 KB Output is correct
86 Correct 4 ms 9820 KB Output is correct
87 Correct 44 ms 14332 KB Output is correct
88 Correct 4 ms 9820 KB Output is correct
89 Correct 4 ms 9660 KB Output is correct
90 Correct 4 ms 9820 KB Output is correct
91 Correct 14 ms 11624 KB Output is correct
92 Correct 64 ms 15968 KB Output is correct
93 Correct 1230 ms 86720 KB Output is correct
94 Correct 688 ms 61448 KB Output is correct
95 Correct 722 ms 64084 KB Output is correct
96 Correct 601 ms 58056 KB Output is correct
97 Correct 561 ms 53676 KB Output is correct
98 Correct 1412 ms 94616 KB Output is correct
99 Correct 1464 ms 96084 KB Output is correct
100 Correct 1227 ms 92672 KB Output is correct
101 Correct 1232 ms 86400 KB Output is correct
102 Correct 1150 ms 78824 KB Output is correct
103 Correct 841 ms 71504 KB Output is correct
104 Correct 4 ms 9816 KB Output is correct
105 Correct 4 ms 9704 KB Output is correct
106 Correct 7 ms 10332 KB Output is correct
107 Correct 87 ms 18840 KB Output is correct
108 Correct 226 ms 30100 KB Output is correct
109 Correct 26 ms 12636 KB Output is correct
110 Correct 5 ms 9820 KB Output is correct
111 Correct 112 ms 21496 KB Output is correct
112 Correct 4 ms 9816 KB Output is correct
113 Correct 4 ms 9820 KB Output is correct
114 Correct 8 ms 10332 KB Output is correct
115 Correct 4 ms 9816 KB Output is correct
116 Correct 12 ms 11192 KB Output is correct
117 Correct 232 ms 33980 KB Output is correct