結果

問題 No.2929 Miracle Branch
ユーザー HIcoderHIcoder
提出日時 2024-10-13 13:07:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,709 bytes
コンパイル時間 1,454 ms
コンパイル使用メモリ 135,736 KB
実行使用メモリ 14,672 KB
最終ジャッジ日時 2024-10-13 13:07:18
合計ジャッジ時間 10,776 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
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 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 3 ms
5,248 KB
testcase_29 AC 3 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 WA -
testcase_35 WA -
testcase_36 AC 4 ms
5,248 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
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>> ans;

    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++;
                ans.push_back({t,x});
                mpc[x]='g';
            }
            x++;
        }
    }
    int sz=mp.size();
    cout<<sz<<endl;
   
    
    if(sz>MAXV){
        cout<<-1<<endl;
        return 0;
    }
    for(auto [t,x]:ans){
        cout<<t<<" "<<x<<endl;
    }

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

}
0