結果

問題 No.2929 Miracle Branch
ユーザー GOTKAKOGOTKAKO
提出日時 2024-10-12 15:50:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,143 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 207,412 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 15:50:30
合計ジャッジ時間 10,200 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 4 ms
5,248 KB
testcase_02 AC 4 ms
5,248 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 4 ms
5,248 KB
testcase_19 AC 4 ms
5,248 KB
testcase_20 WA -
testcase_21 AC 5 ms
5,248 KB
testcase_22 AC 4 ms
5,248 KB
testcase_23 AC 6 ms
5,248 KB
testcase_24 AC 14 ms
5,248 KB
testcase_25 AC 5 ms
5,248 KB
testcase_26 WA -
testcase_27 AC 4 ms
5,248 KB
testcase_28 AC 4 ms
5,248 KB
testcase_29 AC 4 ms
5,248 KB
testcase_30 AC 4 ms
5,248 KB
testcase_31 AC 4 ms
5,248 KB
testcase_32 AC 4 ms
5,248 KB
testcase_33 AC 4 ms
5,248 KB
testcase_34 AC 37 ms
5,248 KB
testcase_35 AC 37 ms
5,248 KB
testcase_36 AC 4 ms
5,248 KB
testcase_37 AC 37 ms
5,248 KB
testcase_38 AC 37 ms
5,248 KB
testcase_39 AC 37 ms
5,248 KB
testcase_40 AC 37 ms
5,248 KB
testcase_41 AC 37 ms
5,248 KB
testcase_42 AC 37 ms
5,248 KB
testcase_43 AC 36 ms
5,248 KB
testcase_44 AC 36 ms
5,248 KB
testcase_45 AC 4 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

}
0