Submission #237716

# Submission time Handle Problem Language Result Execution time Memory
237716 2020-06-08T12:37:56 Z Nucleist Toys (CEOI18_toy) C++14
100 / 100
1318 ms 43916 KB
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
unordered_map<ll,ve>kol;
unordered_map<ll,vector<ll>>dp;
ve fact;
ll t;
vector<ll> rec(ll n){
  if(dp.find(n)!=dp.end())return dp[n];
  ve cur; 
  if(n==1)return cur;
  cur.pb(n-1);
  for(auto it:fact){
    ve now;
    if(!(n%it)){
      now=rec(n/it);
      for(auto it1:now){
        cur.pb(it1+it-1);
      }
    }
  }
  sort(cur.begin(),cur.end());
  auto last = unique(cur.begin(),cur.end());
  cur.erase(last,cur.end());
  return dp[n]=cur;
}
int main()
{
  flash;
  ll n;
  cin>>n;
  t=n;
  set<ll> div;
  for (int i = 1; i <= sqrt(n); ++i)
  {
    if(!(n%i)){
      div.insert(i),div.insert(n/i);
    }
  }
  div.erase(1);
  for(auto it:div){
    fact.pb(it);
  }
  ve ans=rec(n);
  if(n==1)ans.pb(0);
  cout<<ans.size()<<'\n';
  for(auto it:ans)cout<<it<<" ";
  return 0;
}
//code the AC sol !
// BS/queue/map

Compilation message

toy.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
toy.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
toy.cpp: In function 'void setIO(std::__cxx11::string)':
toy.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen((s+".in").c_str(),"r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen((s+".out").c_str(),"w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 256 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 256 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 6 ms 512 KB Output is correct
51 Correct 7 ms 512 KB Output is correct
52 Correct 6 ms 512 KB Output is correct
53 Correct 6 ms 512 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 7 ms 512 KB Output is correct
56 Correct 7 ms 512 KB Output is correct
57 Correct 7 ms 512 KB Output is correct
58 Correct 4 ms 384 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 6 ms 512 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 5 ms 384 KB Output is correct
64 Correct 5 ms 384 KB Output is correct
65 Correct 5 ms 384 KB Output is correct
66 Correct 5 ms 384 KB Output is correct
67 Correct 5 ms 384 KB Output is correct
68 Correct 5 ms 384 KB Output is correct
69 Correct 5 ms 384 KB Output is correct
70 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 256 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 6 ms 512 KB Output is correct
51 Correct 7 ms 512 KB Output is correct
52 Correct 6 ms 512 KB Output is correct
53 Correct 6 ms 512 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 7 ms 512 KB Output is correct
56 Correct 7 ms 512 KB Output is correct
57 Correct 7 ms 512 KB Output is correct
58 Correct 4 ms 384 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 6 ms 512 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 5 ms 384 KB Output is correct
64 Correct 5 ms 384 KB Output is correct
65 Correct 5 ms 384 KB Output is correct
66 Correct 5 ms 384 KB Output is correct
67 Correct 5 ms 384 KB Output is correct
68 Correct 5 ms 384 KB Output is correct
69 Correct 5 ms 384 KB Output is correct
70 Correct 6 ms 384 KB Output is correct
71 Correct 214 ms 9728 KB Output is correct
72 Correct 151 ms 8456 KB Output is correct
73 Correct 206 ms 9696 KB Output is correct
74 Correct 116 ms 5548 KB Output is correct
75 Correct 132 ms 5952 KB Output is correct
76 Correct 312 ms 12128 KB Output is correct
77 Correct 284 ms 11032 KB Output is correct
78 Correct 260 ms 10664 KB Output is correct
79 Correct 243 ms 10592 KB Output is correct
80 Correct 5 ms 384 KB Output is correct
81 Correct 4 ms 384 KB Output is correct
82 Correct 6 ms 512 KB Output is correct
83 Correct 35 ms 1940 KB Output is correct
84 Correct 41 ms 2420 KB Output is correct
85 Correct 12 ms 948 KB Output is correct
86 Correct 5 ms 384 KB Output is correct
87 Correct 43 ms 2828 KB Output is correct
88 Correct 5 ms 384 KB Output is correct
89 Correct 5 ms 384 KB Output is correct
90 Correct 5 ms 384 KB Output is correct
91 Correct 17 ms 1196 KB Output is correct
92 Correct 53 ms 3364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 256 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 6 ms 384 KB Output is correct
39 Correct 4 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 5 ms 384 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 5 ms 384 KB Output is correct
44 Correct 5 ms 384 KB Output is correct
45 Correct 5 ms 384 KB Output is correct
46 Correct 5 ms 384 KB Output is correct
47 Correct 5 ms 384 KB Output is correct
48 Correct 5 ms 384 KB Output is correct
49 Correct 5 ms 384 KB Output is correct
50 Correct 6 ms 512 KB Output is correct
51 Correct 7 ms 512 KB Output is correct
52 Correct 6 ms 512 KB Output is correct
53 Correct 6 ms 512 KB Output is correct
54 Correct 5 ms 384 KB Output is correct
55 Correct 7 ms 512 KB Output is correct
56 Correct 7 ms 512 KB Output is correct
57 Correct 7 ms 512 KB Output is correct
58 Correct 4 ms 384 KB Output is correct
59 Correct 5 ms 384 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 6 ms 512 KB Output is correct
62 Correct 5 ms 384 KB Output is correct
63 Correct 5 ms 384 KB Output is correct
64 Correct 5 ms 384 KB Output is correct
65 Correct 5 ms 384 KB Output is correct
66 Correct 5 ms 384 KB Output is correct
67 Correct 5 ms 384 KB Output is correct
68 Correct 5 ms 384 KB Output is correct
69 Correct 5 ms 384 KB Output is correct
70 Correct 6 ms 384 KB Output is correct
71 Correct 214 ms 9728 KB Output is correct
72 Correct 151 ms 8456 KB Output is correct
73 Correct 206 ms 9696 KB Output is correct
74 Correct 116 ms 5548 KB Output is correct
75 Correct 132 ms 5952 KB Output is correct
76 Correct 312 ms 12128 KB Output is correct
77 Correct 284 ms 11032 KB Output is correct
78 Correct 260 ms 10664 KB Output is correct
79 Correct 243 ms 10592 KB Output is correct
80 Correct 5 ms 384 KB Output is correct
81 Correct 4 ms 384 KB Output is correct
82 Correct 6 ms 512 KB Output is correct
83 Correct 35 ms 1940 KB Output is correct
84 Correct 41 ms 2420 KB Output is correct
85 Correct 12 ms 948 KB Output is correct
86 Correct 5 ms 384 KB Output is correct
87 Correct 43 ms 2828 KB Output is correct
88 Correct 5 ms 384 KB Output is correct
89 Correct 5 ms 384 KB Output is correct
90 Correct 5 ms 384 KB Output is correct
91 Correct 17 ms 1196 KB Output is correct
92 Correct 53 ms 3364 KB Output is correct
93 Correct 1112 ms 39784 KB Output is correct
94 Correct 630 ms 23988 KB Output is correct
95 Correct 711 ms 32556 KB Output is correct
96 Correct 636 ms 23176 KB Output is correct
97 Correct 573 ms 22028 KB Output is correct
98 Correct 1264 ms 43916 KB Output is correct
99 Correct 1318 ms 43184 KB Output is correct
100 Correct 1251 ms 42412 KB Output is correct
101 Correct 1170 ms 41432 KB Output is correct
102 Correct 1020 ms 38088 KB Output is correct
103 Correct 822 ms 35176 KB Output is correct
104 Correct 5 ms 384 KB Output is correct
105 Correct 5 ms 384 KB Output is correct
106 Correct 8 ms 712 KB Output is correct
107 Correct 92 ms 4876 KB Output is correct
108 Correct 229 ms 9684 KB Output is correct
109 Correct 24 ms 1720 KB Output is correct
110 Correct 5 ms 384 KB Output is correct
111 Correct 116 ms 5928 KB Output is correct
112 Correct 5 ms 384 KB Output is correct
113 Correct 5 ms 384 KB Output is correct
114 Correct 9 ms 768 KB Output is correct
115 Correct 5 ms 384 KB Output is correct
116 Correct 12 ms 1040 KB Output is correct
117 Correct 220 ms 10180 KB Output is correct