結果
| 問題 |
No.2929 Miracle Branch
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 15:50:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,143 bytes |
| コンパイル時間 | 2,138 ms |
| コンパイル使用メモリ | 198,760 KB |
| 最終ジャッジ日時 | 2025-02-24 18:13:31 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
long long X; cin >> X;
if(X == 1){
cout << "2" << endl;
cout << "1 2" << endl;
cout << "b g" << endl;
return 0;
}
vector<pair<int,int>> E;
for(int i=3; i<=200000; i++){
int e = 0;
while(X%i == 0) e++,X /= i;
if(e) E.push_back({i,e});
}
if(X == 2) E.push_back({2,1}),X /= 2;
if(X > 2){cout << "-1\n"; return 0;}
int brown = E.size();
long long all = brown;
for(auto [multi,gs] : E) all += 1LL*multi*gs;
if(all > 200000){cout << "-1\n"; return 0;}
vector<int> par(all);
for(int i=1; i<brown; i++) par.at(i) = i-1;
int p = 0,idx = brown;
for(auto [multi,gs] : E){
while(gs--){
for(int i=0; i<multi; i++) par.at(idx++) = p;
p++;
}
}
cout << all << endl;
for(int i=1; i<all; i++) cout << par.at(i)+1 << " " << i+1 << "\n";
cout << "b";
for(int i=1; i<brown; i++) cout << " b";
for(int i=brown; i<all; i++) cout << " g";
cout << endl;
}