結果

問題 No.2929 Miracle Branch
ユーザー hirakuuuuhirakuuuu
提出日時 2024-10-12 16:25:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,777 bytes
コンパイル時間 3,296 ms
コンパイル使用メモリ 252,080 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-12 16:25:35
合計ジャッジ時間 15,006 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 WA -
testcase_02 AC 4 ms
6,820 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 6 ms
6,816 KB
testcase_19 WA -
testcase_20 AC 14 ms
6,820 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 26 ms
6,820 KB
testcase_24 AC 86 ms
6,816 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 4 ms
6,816 KB
testcase_29 AC 4 ms
6,820 KB
testcase_30 AC 4 ms
6,816 KB
testcase_31 AC 4 ms
6,820 KB
testcase_32 AC 4 ms
6,820 KB
testcase_33 AC 4 ms
6,816 KB
testcase_34 AC 279 ms
6,816 KB
testcase_35 AC 287 ms
6,816 KB
testcase_36 AC 4 ms
6,816 KB
testcase_37 AC 276 ms
6,820 KB
testcase_38 AC 294 ms
6,820 KB
testcase_39 AC 276 ms
6,820 KB
testcase_40 AC 295 ms
6,820 KB
testcase_41 AC 271 ms
6,816 KB
testcase_42 AC 290 ms
6,816 KB
testcase_43 AC 273 ms
6,816 KB
testcase_44 AC 274 ms
6,816 KB
testcase_45 AC 81 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i >= n; i--)
#define inr(l, x, r) (l <= x && x < r)
#define ll long long
#define ld long double

// using mint = modint1000000007;
// using mint = modint998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1e18;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    ll x; cin >> x;
    if(x == 1){
        cout << "2" << endl;
        cout << "1 2" << endl;
        cout << "b g" << endl;
        return 0;
    }
    vector<ll> p, q;
    ll sum_q = 0;
    auto f = [&](auto self, ll y) -> bool {
        if(y == 1){
            p = q;
            return true;
        }
        int start = 2;
        bool res = false;
        if(!q.empty()) start = q.back();
        rep(i, start, min(200000LL, y)+1){
            if(y%i == 0){
                if(sum_q+q.size()+(i+1) <= 200000){
                    q.push_back(i);
                    sum_q += i;
                    res |= self(self, y/i);
                    q.pop_back();
                }
            }
        }
        return res;
    };


    if(!f(f, x)){
        cout << -1 << endl;
        return 0;
    }
    int n = (int)p.size();
    int sum_p = 0;
    rep(i, 0, n) sum_p += p[i];
    cout << sum_p+n << endl;
    int adj = n+1;
    rep(i, 0, n){
        if(i > 0) cout << i << ' ' << i+1 << endl;
        rep(j, 0, p[i]){
            cout << i+1 << ' ' << adj++ << endl;
        }
    }
    rep(i, 0, n){
        cout << 'b' << ' ';
    }
    rep(i, 0, sum_p){
        cout << 'g' << ' ';
    }
    cout << endl;

    
    return 0;
}
0