結果
問題 | No.2929 Miracle Branch |
ユーザー |
![]() |
提出日時 | 2024-10-12 15:53:46 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 305 ms / 2,000 ms |
コード長 | 1,543 bytes |
コンパイル時間 | 4,462 ms |
コンパイル使用メモリ | 266,156 KB |
実行使用メモリ | 5,776 KB |
最終ジャッジ日時 | 2024-10-12 15:54:02 |
合計ジャッジ時間 | 15,092 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#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]) { edge.emplace_back(i,c.size()); c.push_back('g'); 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; }