結果
問題 | No.2929 Miracle Branch |
ユーザー |
|
提出日時 | 2024-10-12 16:28:10 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,324 bytes |
コンパイル時間 | 2,962 ms |
コンパイル使用メモリ | 249,276 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 16:28:26 |
合計ジャッジ時間 | 12,657 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 5 WA * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/modint>using namespace atcoder;#ifdef DEFINED_ONLY_IN_LOCAL#include <dump.hpp>#define dump(...) cpp_dump(__VA_ARGS__)#else#undef dump#define dump(...)#endif#define rep(i, n) for (int i = 0; i < n; i++)template <class T> istream& operator>>(istream& I, vector<T>& V) { for (T& X : V) I >> X; return I; }int main() {long x;cin >> x;if (x == 1) {cout << 2 << endl;cout << 1 << " " << 2 << endl;cout << "b g" << endl;return 0;}vector<int> b;while (x > 1) {bool find = false;for (int i = 2; i <= 2e5; i++) {if (x % i == 0) {find = true;b.push_back(i);x /= i;break;}}if (!find) {cout << -1 << endl;return 0;}}cout << reduce(b.begin(), b.end()) + b.size() << endl;for (int i = 0; i < b.size() - 1; i++) {cout << i << " " << i + 1 << endl;}int idx = b.size();rep(i, b.size()) {rep(j, b[i]) {cout << i << " " << idx++ << endl;}}rep(i, b.size()) cout << "b ";rep(i, reduce(b.begin(), b.end())) cout << "g ";cout << endl;return 0;}