結果
問題 | No.2929 Miracle Branch |
ユーザー |
![]() |
提出日時 | 2024-10-12 15:51:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,543 bytes |
コンパイル時間 | 4,370 ms |
コンパイル使用メモリ | 254,460 KB |
最終ジャッジ日時 | 2025-02-24 18:14:32 |
ジャッジサーバーID (参考情報) |
judge4 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 8 WA * 35 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair<ll,ll>; using lb = long double; using T = tuple<ll, ll, ll>; #ifdef LOCAL # include <debug_print.hpp> # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast<void>(0)) #endif int main() { ll x; cin >> x; vector<int> vs; if(x==1) { cout << 2 << endl; cout << 1 << " " << 2 << endl; cout << 'b' << " " << 'g' << endl; return 0; } for(int i=3;i<=2e5;i++) { while(x%i==0) { vs.push_back(i); x /= i; } } if(x%2==0) { vs.push_back(2); x/=2; } if(x!=1) { cout << -1 << endl; return 0; } int n = vs.size(); vector<char> c; rep(i,n) c.push_back('b'); vector<pair<int,int>> edge; for(int i=1;i<n;i++) edge.emplace_back(i-1,i); for(int i=0;i<n;i++) { rep(j,vs[i]) { c.push_back('g'); edge.emplace_back(i,c.size()); if(c.size()>2e5) { cout << -1 << endl; return 0; } } } cout << c.size() << endl; for(auto e : edge) { cout << e.first+1 << " " << e.second+1 << endl; } for(auto t : c) { cout << t << " "; } cout << endl; return 0; }