結果
問題 | No.2929 Miracle Branch |
ユーザー | kwm_t |
提出日時 | 2024-10-12 16:23:58 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,797 bytes |
コンパイル時間 | 5,922 ms |
コンパイル使用メモリ | 323,508 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-10-12 16:24:18 |
合計ジャッジ時間 | 16,334 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
6,820 KB |
testcase_01 | AC | 5 ms
6,820 KB |
testcase_02 | AC | 6 ms
6,820 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | RE | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 8 ms
6,816 KB |
testcase_19 | AC | 8 ms
6,820 KB |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 25 ms
6,816 KB |
testcase_24 | AC | 85 ms
6,820 KB |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | AC | 7 ms
6,816 KB |
testcase_28 | AC | 6 ms
6,816 KB |
testcase_29 | AC | 6 ms
6,816 KB |
testcase_30 | AC | 5 ms
6,816 KB |
testcase_31 | AC | 6 ms
6,816 KB |
testcase_32 | AC | 6 ms
6,820 KB |
testcase_33 | AC | 6 ms
6,820 KB |
testcase_34 | AC | 256 ms
6,820 KB |
testcase_35 | AC | 256 ms
6,820 KB |
testcase_36 | AC | 6 ms
6,816 KB |
testcase_37 | AC | 278 ms
6,820 KB |
testcase_38 | AC | 266 ms
6,820 KB |
testcase_39 | AC | 267 ms
6,816 KB |
testcase_40 | AC | 261 ms
6,820 KB |
testcase_41 | AC | 282 ms
6,820 KB |
testcase_42 | AC | 283 ms
6,820 KB |
testcase_43 | AC | 265 ms
6,816 KB |
testcase_44 | RE | - |
testcase_45 | AC | 6 ms
6,820 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; using mint = modint998244353; const int mod = 998244353; //const int INF = 1e9; const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair<int,int> template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long x; cin >> x; vector<long long>cand; rep2(i, 1, 200001) { if (0 == x % i)cand.push_back(i); } map<long long, long long>mp;// {p*q,min{p+q}}; map<long long, pair<long long, long long>>mp2; rep(i, cand.size())rep(j, cand.size()) { long long x = cand[i] * cand[j]; long long y = cand[i] + cand[j]; if (mp.count(x)) { if (chmin(mp[x], y))mp2[x] = { cand[i],cand[j] }; } else { mp[x] = y; mp2[x] = { cand[i],cand[j] }; } } vector<long long>mn(3, LINF); mn[0] = x + 1; if (mp.count(x))mn[1] = 2 + mp[x]; int tmp = 0; rep2(i, 1, 200001) { if (0 != x % i)continue; if (!mp.count(x / i))continue; if (chmin(mn[2], 3 + i + mp[x / i]))tmp = i; } long long mnn = LINF; rep(i, 3)chmin(mnn, mn[i]); if (mnn > 200000) { cout << -1 << endl; return 0; } cout << mnn << endl; if (mnn == mn[0]) { rep(i, mnn - 1)cout << 1 << " " << i + 2 << endl; vector<char>c(mnn, 'g'); c[0] = 'b'; rep(i, mnn)cout << c[i] << " "; cout << endl; } else if (mnn == mn[1]) { long long p = mp2[x].first; long long q = mp2[x].second; rep(i, p)cout << i + 1 << " " << p + q + 1 << endl; rep(i, q)cout << i + 1 + p << " " << p + q + 2 << endl; cout << p + q + 1 << " " << p + q + 2 << endl; vector<char>c(mnn, 'g'); c[mnn - 2] = 'b'; c[mnn - 1] = 'b'; rep(i, mnn)cout << c[i] << " "; cout << endl; } else { return -1; long long p = tmp; long long q = mp2[x / tmp].first; long long r = mp2[x / tmp].second; rep(i, p)cout << i + 1 << " " << p + q + r + 1 << endl; rep(i, q)cout << i + 1 + p << " " << p + q + r + 2 << endl; rep(i, r)cout << i + 1 + p + q << " " << p + q + r + 3 << endl; cout << p + q + r + 1 << " " << p + q + r + 2 << endl; cout << p + q + r + 2 << " " << p + q + r + 3 << endl; vector<char>c(mnn, 'g'); c[mnn - 3] = 'b'; c[mnn - 2] = 'b'; c[mnn - 1] = 'b'; rep(i, mnn)cout << c[i] << " "; cout << endl; } return 0; }