이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#define int long long
#define pii pair<int, int>
#define ti3 tuple<int, int, int>
#define ti4 tuple<int, int, int, int>
// This is like my secret account; yes it's like that ~ Baek Jiheon, Feel Good (Secret Code)
using namespace std;
map<pii, int> off;
unordered_set<int> *dfs(int x, int s){
unordered_set<int> * curr_set = new unordered_set<int>();
curr_set->insert(x-1);
off[{x, s}] = 0;
for (int i = s; i*i<=x; i++){
if (x%i != 0) continue;
unordered_set<int> *child = dfs(x/i, i);
if (child->size() <= curr_set->size()){
int x1 = off[{x/i, i}];
int p = off[{x, s}];
for (auto j : *child){
curr_set->insert(j + x1 + i-1 - p);
}
delete child;
} else {
swap(child, curr_set);
swap(off[{x, s}], off[{x/i, i}]);
off[{x, s}] += i - 1;
int x1 = off[{x/i, i}];
int p = off[{x, s}];
for (auto j : *child){
curr_set->insert(j + x1 - p);
}
delete child;
}
}
return curr_set;
}
main(){
int x; cin >> x;
unordered_set<int> *ans = dfs(x, 2);
vector<int> ot;
int x2 = off[{x, 2}];
for (auto i : *ans){
ot.push_back(i + x2);
}
sort(ot.begin(), ot.end());
cout << ot.size() << '\n';
for (auto i : ot) cout << i << ' ';
}
컴파일 시 표준 에러 (stderr) 메시지
toy.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
37 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |