結果
| 問題 |
No.2929 Miracle Branch
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 16:16:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,160 bytes |
| コンパイル時間 | 3,119 ms |
| コンパイル使用メモリ | 203,460 KB |
| 最終ジャッジ日時 | 2025-02-24 18:29:41 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 42 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const long long N_MAX = 200000;
int main(){
long long X;
cin >> X;
if (X == 1){
cout << "2\n1 2\nb g" << endl;
return 0;
}
vector<pair<int, vector<int>>> P;
vector<int> A;
long long sum = 0;
auto dfs = [&](auto dfs){
if (X == 1){
if (sum + (int) A.size() <= N_MAX){
P.push_back(make_pair(sum, A));
}
return;
}
for (int i = 2; i <= min(X, N_MAX); i++){
if (X % i == 0){
X /= i;
A.push_back(i);
sum += i;
dfs(dfs);
X *= i;
sum -= i;
A.pop_back();
}
}
};
dfs(dfs);
if (!P.empty()){
auto [_, S] = *min_element(P.begin(), P.end());
cout << accumulate(S.begin(), S.end(), 0) + S.size() << endl;
for (int i = 0; i < (int) S.size() - 1; i++){
cout << i + 1 << ' ' << i + 2 << endl;
}
int cnt = S.size();
for (int i = 0; i < (int) S.size(); i++){
for (int j = 0; j < S[i]; j++){
cnt++;
cout << i + 1 << ' ' << cnt << endl;
}
}
for (int i = 0; i < S.size(); i++){
cout << "b ";
}
for (int i = 0; i < accumulate(S.begin(), S.end(), 0); i++){
cout << "g ";
}
cout << endl;
} else {
cout << -1 << endl;
}
}