結果
| 問題 |
No.2929 Miracle Branch
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 16:41:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 295 ms / 2,000 ms |
| コード長 | 1,264 bytes |
| コンパイル時間 | 3,003 ms |
| コンパイル使用メモリ | 249,648 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 16:41:53 |
| 合計ジャッジ時間 | 13,420 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#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;
for (int i = 3; i <= 2e5; i++) {
while (x % i == 0) {
x /= i;
b.push_back(i);
}
}
if (x == 2) b.push_back(x), x /= 2;
int sz = reduce(b.begin(), b.end()) + b.size();
if (sz > 2e5 or x != 1) {
cout << -1 << endl;
return 0;
}
cout << sz << 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;
}