답안 #503603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503603 2022-01-08T12:15:18 Z andrei_boaca Toys (CEOI18_toy) C++17
100 / 100
4185 ms 58756 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef pair<int,int> pii;
int n;
set<int> sol;
vector<int> v;
queue<vector<int>> coada;
unordered_map<int,int> use;
map<vector<int>,int> vuse;
int niv;
int main()
{
    cin>>n;
    int d=2;
    while(n>1)
    {
        while(n%d==0)
        {
            v.push_back(d);
            n/=d;
        }
        d++;
        if(d%2==0)
            d++;
        if(d*d>n&&n>1)
        {
            v.push_back(n);
            break;
        }
    }
    sort(v.begin(),v.end());
    coada.push(v);
    vuse[v]=1;
    niv=v.size();
    while(!coada.empty())
    {
        vector<int> a=coada.front();
        coada.pop();
        int suma=0;
        for(auto i:a)
            suma+=i;
        suma-=a.size();
        sol.insert(suma);
        pii x={0,0};
        for(int i=0;i<a.size();i++)
            for(int j=i+1;j<a.size();j++)
                if(i!=x.first||j!=x.second)
                {
                    x={i,j};
                    int s=suma-a[i]-a[j]+1+a[i]*a[j];
                    if(use[s]<20)
                    {
                        vector<int> aux;
                        for(int p=0;p<a.size();p++)
                            if(p!=i&&p!=j)
                                aux.push_back(a[p]);
                        aux.push_back(a[i]*a[j]);
                        sort(aux.begin(),aux.end());
                        if(!vuse[aux])
                        {
                            use[s]++;
                            vuse[aux]=1;
                            sol.insert(s);
                            coada.push(aux);
                        }
                    }
                }
    }
    cout<<sol.size()<<'\n';
    for(auto i:sol)
        cout<<i<<' ';
    return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(int i=0;i<a.size();i++)
      |                     ~^~~~~~~~~
toy.cpp:47:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for(int j=i+1;j<a.size();j++)
      |                           ~^~~~~~~~~
toy.cpp:55:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |                         for(int p=0;p<a.size();p++)
      |                                     ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 292 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 292 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 292 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 2 ms 292 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 292 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 292 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 2 ms 292 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 288 KB Output is correct
50 Correct 7 ms 600 KB Output is correct
51 Correct 7 ms 460 KB Output is correct
52 Correct 8 ms 588 KB Output is correct
53 Correct 6 ms 460 KB Output is correct
54 Correct 3 ms 332 KB Output is correct
55 Correct 12 ms 740 KB Output is correct
56 Correct 14 ms 728 KB Output is correct
57 Correct 9 ms 716 KB Output is correct
58 Correct 0 ms 292 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 2 ms 332 KB Output is correct
61 Correct 10 ms 508 KB Output is correct
62 Correct 3 ms 332 KB Output is correct
63 Correct 2 ms 292 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 7 ms 460 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 292 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 292 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 2 ms 292 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 288 KB Output is correct
50 Correct 7 ms 600 KB Output is correct
51 Correct 7 ms 460 KB Output is correct
52 Correct 8 ms 588 KB Output is correct
53 Correct 6 ms 460 KB Output is correct
54 Correct 3 ms 332 KB Output is correct
55 Correct 12 ms 740 KB Output is correct
56 Correct 14 ms 728 KB Output is correct
57 Correct 9 ms 716 KB Output is correct
58 Correct 0 ms 292 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 2 ms 332 KB Output is correct
61 Correct 10 ms 508 KB Output is correct
62 Correct 3 ms 332 KB Output is correct
63 Correct 2 ms 292 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 7 ms 460 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 603 ms 14412 KB Output is correct
72 Correct 378 ms 11208 KB Output is correct
73 Correct 542 ms 13060 KB Output is correct
74 Correct 330 ms 9220 KB Output is correct
75 Correct 341 ms 9840 KB Output is correct
76 Correct 976 ms 18992 KB Output is correct
77 Correct 1078 ms 18120 KB Output is correct
78 Correct 820 ms 16476 KB Output is correct
79 Correct 968 ms 16264 KB Output is correct
80 Correct 0 ms 204 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 37 ms 616 KB Output is correct
83 Correct 310 ms 5040 KB Output is correct
84 Correct 230 ms 4936 KB Output is correct
85 Correct 58 ms 1568 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 283 ms 5692 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 0 ms 204 KB Output is correct
90 Correct 1 ms 292 KB Output is correct
91 Correct 34 ms 1864 KB Output is correct
92 Correct 143 ms 5768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 292 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 1 ms 292 KB Output is correct
26 Correct 1 ms 288 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 2 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 2 ms 292 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 288 KB Output is correct
50 Correct 7 ms 600 KB Output is correct
51 Correct 7 ms 460 KB Output is correct
52 Correct 8 ms 588 KB Output is correct
53 Correct 6 ms 460 KB Output is correct
54 Correct 3 ms 332 KB Output is correct
55 Correct 12 ms 740 KB Output is correct
56 Correct 14 ms 728 KB Output is correct
57 Correct 9 ms 716 KB Output is correct
58 Correct 0 ms 292 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 2 ms 332 KB Output is correct
61 Correct 10 ms 508 KB Output is correct
62 Correct 3 ms 332 KB Output is correct
63 Correct 2 ms 292 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 7 ms 460 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 603 ms 14412 KB Output is correct
72 Correct 378 ms 11208 KB Output is correct
73 Correct 542 ms 13060 KB Output is correct
74 Correct 330 ms 9220 KB Output is correct
75 Correct 341 ms 9840 KB Output is correct
76 Correct 976 ms 18992 KB Output is correct
77 Correct 1078 ms 18120 KB Output is correct
78 Correct 820 ms 16476 KB Output is correct
79 Correct 968 ms 16264 KB Output is correct
80 Correct 0 ms 204 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 37 ms 616 KB Output is correct
83 Correct 310 ms 5040 KB Output is correct
84 Correct 230 ms 4936 KB Output is correct
85 Correct 58 ms 1568 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 283 ms 5692 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 0 ms 204 KB Output is correct
90 Correct 1 ms 292 KB Output is correct
91 Correct 34 ms 1864 KB Output is correct
92 Correct 143 ms 5768 KB Output is correct
93 Correct 3299 ms 51028 KB Output is correct
94 Correct 1810 ms 35940 KB Output is correct
95 Correct 2059 ms 38328 KB Output is correct
96 Correct 1790 ms 33924 KB Output is correct
97 Correct 1798 ms 31852 KB Output is correct
98 Correct 3952 ms 57816 KB Output is correct
99 Correct 3894 ms 58756 KB Output is correct
100 Correct 3845 ms 55968 KB Output is correct
101 Correct 4185 ms 56512 KB Output is correct
102 Correct 3821 ms 51584 KB Output is correct
103 Correct 2707 ms 44848 KB Output is correct
104 Correct 0 ms 204 KB Output is correct
105 Correct 0 ms 292 KB Output is correct
106 Correct 87 ms 980 KB Output is correct
107 Correct 1062 ms 13304 KB Output is correct
108 Correct 1340 ms 21972 KB Output is correct
109 Correct 206 ms 3684 KB Output is correct
110 Correct 0 ms 204 KB Output is correct
111 Correct 837 ms 13872 KB Output is correct
112 Correct 0 ms 204 KB Output is correct
113 Correct 1 ms 296 KB Output is correct
114 Correct 8 ms 716 KB Output is correct
115 Correct 0 ms 204 KB Output is correct
116 Correct 25 ms 1432 KB Output is correct
117 Correct 791 ms 19388 KB Output is correct