結果

問題 No.2929 Miracle Branch
ユーザー HIcoderHIcoder
提出日時 2024-10-13 13:16:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,819 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 134,516 KB
実行使用メモリ 17,236 KB
最終ジャッジ日時 2024-10-13 13:16:39
合計ジャッジ時間 12,878 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 6 ms
5,248 KB
testcase_19 AC 8 ms
5,248 KB
testcase_20 AC 11 ms
5,248 KB
testcase_21 AC 18 ms
5,248 KB
testcase_22 WA -
testcase_23 AC 29 ms
5,248 KB
testcase_24 AC 106 ms
7,504 KB
testcase_25 WA -
testcase_26 AC 5 ms
5,248 KB
testcase_27 AC 5 ms
5,248 KB
testcase_28 AC 4 ms
5,248 KB
testcase_29 AC 4 ms
5,248 KB
testcase_30 AC 5 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 357 ms
17,236 KB
testcase_35 AC 374 ms
17,232 KB
testcase_36 AC 4 ms
5,248 KB
testcase_37 AC 351 ms
17,228 KB
testcase_38 AC 371 ms
17,232 KB
testcase_39 AC 351 ms
17,236 KB
testcase_40 AC 377 ms
17,236 KB
testcase_41 AC 351 ms
17,236 KB
testcase_42 AC 357 ms
17,232 KB
testcase_43 AC 353 ms
15,692 KB
testcase_44 AC 353 ms
17,228 KB
testcase_45 AC 4 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<numeric>
#include<algorithm>
using namespace std;
using ll = long long;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,ll> P;
typedef pair<int,P> PP; 
const ll MOD=998244353;
const int dy[]={0,1,0,-1};
const int dx[]={1,0,-1,0};


int main(){
    ll X;
    cin >> X;

    if(X==1){
        cout<<2<<endl;
        cout<<1<<" "<<2<<endl;
        cout<<"b g"<<endl;
        return 0;
    }

    const int MAXV=2*100000;
    map<ll,ll> mp;
    for(ll v=2;v<=MAXV;v++){
        if(X%v==0){
            ll cnt=0;
            while(X%v==0){
                X/=v;
                cnt++;
            }
            mp[v]=cnt;
        }
    }

    ll tmp_v=0;
    for(auto [v,num]:mp){
        tmp_v+=(v+1)*num;
        // cout<<v<<" "<<num<<endl;
    }


    if(mp.size()==0 || X>1 || tmp_v>MAXV){
        //まだXは割り切れないすうがのこっている
        cout<<-1<<endl;
        return 0;
    }
    vector<pair<int,int>> cand;

    map<int,char> mpc;
    int x=1;
    for(auto [v,num]:mp){
        for(int i=0;i<num;i++){
            int t=x;
            mpc[t]='b';
            for(int j=0;j<v;j++){
                x++;
                cand.push_back({t,x});
                mpc[x]='g';
            }
            x++;
        }
    }
    int sz=mpc.size();
    cout<<sz<<endl;

    auto ans=cand;


    for(int i=0;i+1<cand.size();i++){
        if(cand[i].first!=cand[i+1].first){
            ans.push_back({cand[i].first,cand[i+1].first});
        }
    }

    for(auto [t,x]:ans){
        cout<<t<<" "<<x<<endl;
    }

    for(int i=1;i<x;i++){
        cout<<mpc[i]<<(i==x-1?'\n':' ');
    }

}
0