結果
問題 | No.2929 Miracle Branch |
ユーザー | yasunori |
提出日時 | 2024-10-12 15:31:12 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 301 ms / 2,000 ms |
コード長 | 4,281 bytes |
コンパイル時間 | 2,471 ms |
コンパイル使用メモリ | 215,032 KB |
実行使用メモリ | 10,056 KB |
最終ジャッジ日時 | 2024-10-12 15:31:31 |
合計ジャッジ時間 | 13,490 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
5,248 KB |
testcase_01 | AC | 6 ms
5,248 KB |
testcase_02 | AC | 7 ms
5,248 KB |
testcase_03 | AC | 7 ms
5,248 KB |
testcase_04 | AC | 7 ms
5,248 KB |
testcase_05 | AC | 7 ms
5,248 KB |
testcase_06 | AC | 6 ms
5,248 KB |
testcase_07 | AC | 6 ms
5,248 KB |
testcase_08 | AC | 7 ms
5,248 KB |
testcase_09 | AC | 7 ms
5,248 KB |
testcase_10 | AC | 6 ms
5,248 KB |
testcase_11 | AC | 6 ms
5,248 KB |
testcase_12 | AC | 7 ms
5,248 KB |
testcase_13 | AC | 6 ms
5,248 KB |
testcase_14 | AC | 7 ms
5,248 KB |
testcase_15 | AC | 6 ms
5,248 KB |
testcase_16 | AC | 6 ms
5,248 KB |
testcase_17 | AC | 7 ms
5,248 KB |
testcase_18 | AC | 9 ms
5,248 KB |
testcase_19 | AC | 10 ms
5,248 KB |
testcase_20 | AC | 13 ms
5,248 KB |
testcase_21 | AC | 19 ms
5,248 KB |
testcase_22 | AC | 6 ms
5,248 KB |
testcase_23 | AC | 30 ms
5,248 KB |
testcase_24 | AC | 93 ms
5,376 KB |
testcase_25 | AC | 16 ms
5,248 KB |
testcase_26 | AC | 7 ms
5,248 KB |
testcase_27 | AC | 8 ms
5,248 KB |
testcase_28 | AC | 6 ms
5,248 KB |
testcase_29 | AC | 6 ms
5,248 KB |
testcase_30 | AC | 6 ms
5,248 KB |
testcase_31 | AC | 6 ms
5,248 KB |
testcase_32 | AC | 6 ms
5,248 KB |
testcase_33 | AC | 6 ms
5,248 KB |
testcase_34 | AC | 299 ms
9,924 KB |
testcase_35 | AC | 298 ms
9,928 KB |
testcase_36 | AC | 6 ms
5,248 KB |
testcase_37 | AC | 301 ms
9,804 KB |
testcase_38 | AC | 300 ms
9,920 KB |
testcase_39 | AC | 300 ms
10,056 KB |
testcase_40 | AC | 295 ms
9,804 KB |
testcase_41 | AC | 294 ms
9,924 KB |
testcase_42 | AC | 297 ms
9,928 KB |
testcase_43 | AC | 299 ms
9,928 KB |
testcase_44 | AC | 299 ms
9,928 KB |
testcase_45 | AC | 6 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; template <typename T> using min_priority_queue = priority_queue<T,vector<T>,greater<T>>; random_device seed_gen; mt19937 engine(seed_gen()); int64_t get_time(){ struct::timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return t.tv_sec * int64_t(1'000'000'000) + t.tv_nsec; } template<typename T> void invec(vector<T> &v){ for(auto &i : v) cin >> i; return; } template<typename T> void outvec(vector<T> &v, string s = " "){ bool b = false; for(auto i : v){ if(b) cout << s; else b = true; cout << i; } cout << endl; return; } template <typename T> bool chmin(T &a, const T& b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } template <typename T> bool chmax(T &a, const T& b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } bool yn(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; return b; } bool check_with_simple_solution; bool calc_time; bool random_input; bool debug_output; int num_of_testcase; using ans_type = int64_t; void input(){ if(num_of_testcase > 1){ } if(random_input){ } else{ } return; } void output_input(){ return; } void pre_solve(){ return; } ans_type solve(){ int64_t z; cin >> z; int64_t v_max = 200'000; map<int64_t, int64_t> P; for(int i = 2; i < v_max * 2; i++) { while(z % i == 0) { P[i]++; z /= i; } } if(z > 1) { cout << -1 << endl; return 0; } if(P.count(2) && P[2] >= 2) { int64_t p2 = P[2]; P[2] %= 2; P[4] += p2 / 2; } if(P.size() == 0) P[1] = 1; int64_t v = 0; for(auto [p, a] : P) { v += (p + 1) * a; } if(v > v_max) { cout << -1 << endl; return 0; } vector<vector<int>> G(v); vector<int> C(v); int x = -1; int y = -1; for(auto [p, a] : P) { for(int i = 0; i < a; i++) { int b = y+1; C[b] = 0; if(x >= 0) { G[x].push_back(b); } for(int j = 1; j <= p; j++) { G[b].push_back(b + j); C[b + j] = 1; } x = b; y = b + p; } } cout << v << endl; for(int i = 0; i < v; i++) { for(int j : G[i]) { cout << i+1 << " " << j+1 << endl; } } for(int i = 0; i < v; i++) { if(i) cout << " "; if(C[i]) cout << "g"; else cout << "b"; } cout << endl; return ans_type(); } ans_type solve_simple(){ return ans_type(); } void output(ans_type ans){ return; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20); check_with_simple_solution = 0; calc_time = 0; random_input = 0; debug_output = 0; num_of_testcase = 1; if(num_of_testcase == 0) cin >> num_of_testcase; pre_solve(); if(check_with_simple_solution){ for(int i = 0; i < num_of_testcase; i++){ if(debug_output) cout << "begin case " << i << " " << string(16, '=') << endl; input(); ans_type ans = solve(); if(debug_output) cout << string(16, '=') << endl; ans_type ans_simple = solve_simple(); if(ans != ans_simple){ cout << "input: " << endl; output_input(); cout << "output: " << endl; output(ans); cout << "expected: " << endl; output(ans_simple); } if(debug_output) cout << "end case " << i << " " << string(16, '=') << endl; } } else{ int64_t time_start = get_time(); for(int i = 0; i < num_of_testcase; i++){ input(); output(solve()); } int64_t time_end = get_time(); if(calc_time){ double time_per_case = (time_end - time_start) / (1e9 * num_of_testcase); cout << fixed << setprecision(3) << time_per_case << "[second/case]" << endl; } } return 0; }