結果
問題 | No.2929 Miracle Branch |
ユーザー |
![]() |
提出日時 | 2024-10-12 16:20:38 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 1,165 bytes |
コンパイル時間 | 3,601 ms |
コンパイル使用メモリ | 249,428 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 16:20:51 |
合計ジャッジ時間 | 9,488 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, x, y) for (auto i = (x); i < (y); i++) #define RREP(i, x, y) for (auto i = (y) - 1; (x) <= i; i--) #define ALL(x) (x).begin(), (x).end() #pragma GCC optimize("O3") int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll X; cin >> X; if(X == 1){ cout << "2\n1 2\nb g\n"; return 0; } vector<int> m; while(X % 4 == 0){ m.push_back(4); X /= 4; } REP(i, 2, 200000){ while(X % i == 0){ m.push_back(i); X /= i; } } if(X != 1){ cout << -1 << "\n"; return 0; } ll sum = 0; for(auto v: m){ sum += v; } if(200000 < ssize(m) + sum){ cout << -1 << "\n"; return 0; } cout << ssize(m) + sum << "\n"; REP(i, 1, ssize(m)){ cout << i << " " << i+1 << "\n"; } int idx = ssize(m) + 1; REP(i, 0, ssize(m)){ REP(j, 0, m[i]){ cout << i+1 << " " << idx << "\n"; idx++; } } REP(i, 0, ssize(m)){ cout << "b "; } REP(i, 0, sum){ cout << "g "; } cout << "\n"; return 0; } /* File : ~/yukicoder/midoriika_3rd/K.cpp Date : 2024/10/12 Time : 16:02:23 */