結果
問題 | No.2929 Miracle Branch |
ユーザー |
|
提出日時 | 2024-10-12 16:35:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,264 bytes |
コンパイル時間 | 3,026 ms |
コンパイル使用メモリ | 249,692 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-12 16:36:15 |
合計ジャッジ時間 | 13,377 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 17 |
ソースコード
#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 long x;cin >> x;if (x == 1) {cout << 2 << endl;cout << 1 << " " << 2 << endl;cout << "b g" << endl;return 0;}vector<int> b;for (int i = 2; i <= 2e5; i++) {while (x % i == 0) {x /= i;b.push_back(i);}}int sz = reduce(b.begin(), b.end()) + b.size();if (sz > 2e5 or x != 1) {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 + 1 << " " << i + 2 << endl;}int idx = b.size() + 1;rep(i, b.size()) {rep(j, b[i]) {cout << i + 1 << " " << idx++ << endl;}}rep(i, b.size()) cout << "b ";rep(i, reduce(b.begin(), b.end())) cout << "g ";cout << endl;return 0;}