結果
問題 | No.5016 Worst Mayor |
ユーザー | trineutron |
提出日時 | 2023-04-29 02:03:13 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,376 ms / 2,000 ms |
コード長 | 4,278 bytes |
コンパイル時間 | 990 ms |
コンパイル使用メモリ | 98,144 KB |
実行使用メモリ | 24,360 KB |
スコア | 2,717,149,715 |
平均クエリ数 | 400.00 |
最終ジャッジ日時 | 2023-04-29 12:37:33 |
合計ジャッジ時間 | 63,070 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,205 ms
24,024 KB |
testcase_01 | AC | 1,024 ms
24,072 KB |
testcase_02 | AC | 1,219 ms
23,412 KB |
testcase_03 | AC | 1,237 ms
24,036 KB |
testcase_04 | AC | 1,064 ms
24,012 KB |
testcase_05 | AC | 1,253 ms
24,012 KB |
testcase_06 | AC | 1,095 ms
23,520 KB |
testcase_07 | AC | 1,227 ms
24,024 KB |
testcase_08 | AC | 1,212 ms
24,276 KB |
testcase_09 | AC | 1,160 ms
23,856 KB |
testcase_10 | AC | 1,246 ms
23,652 KB |
testcase_11 | AC | 1,213 ms
24,072 KB |
testcase_12 | AC | 1,317 ms
24,288 KB |
testcase_13 | AC | 876 ms
24,024 KB |
testcase_14 | AC | 1,265 ms
24,288 KB |
testcase_15 | AC | 1,201 ms
23,544 KB |
testcase_16 | AC | 1,236 ms
23,640 KB |
testcase_17 | AC | 1,251 ms
24,336 KB |
testcase_18 | AC | 1,290 ms
23,544 KB |
testcase_19 | AC | 1,292 ms
24,360 KB |
testcase_20 | AC | 891 ms
24,024 KB |
testcase_21 | AC | 1,115 ms
23,412 KB |
testcase_22 | AC | 1,226 ms
23,556 KB |
testcase_23 | AC | 1,307 ms
23,676 KB |
testcase_24 | AC | 972 ms
23,424 KB |
testcase_25 | AC | 1,319 ms
23,376 KB |
testcase_26 | AC | 864 ms
23,544 KB |
testcase_27 | AC | 1,212 ms
24,360 KB |
testcase_28 | AC | 1,283 ms
23,676 KB |
testcase_29 | AC | 1,184 ms
23,544 KB |
testcase_30 | AC | 1,059 ms
23,628 KB |
testcase_31 | AC | 1,199 ms
24,048 KB |
testcase_32 | AC | 1,233 ms
23,544 KB |
testcase_33 | AC | 1,210 ms
23,664 KB |
testcase_34 | AC | 1,123 ms
24,360 KB |
testcase_35 | AC | 1,255 ms
23,532 KB |
testcase_36 | AC | 1,109 ms
23,412 KB |
testcase_37 | AC | 1,248 ms
23,424 KB |
testcase_38 | AC | 870 ms
23,364 KB |
testcase_39 | AC | 905 ms
24,024 KB |
testcase_40 | AC | 1,234 ms
24,036 KB |
testcase_41 | AC | 1,090 ms
23,388 KB |
testcase_42 | AC | 1,156 ms
23,376 KB |
testcase_43 | AC | 1,156 ms
24,276 KB |
testcase_44 | AC | 1,111 ms
23,820 KB |
testcase_45 | AC | 1,102 ms
23,544 KB |
testcase_46 | AC | 1,376 ms
24,324 KB |
testcase_47 | AC | 1,061 ms
23,652 KB |
testcase_48 | AC | 1,259 ms
23,664 KB |
testcase_49 | AC | 1,087 ms
23,856 KB |
ソースコード
#include <array> #include <cassert> #include <cmath> #include <iostream> #include <random> class xrand { uint64_t x; public: using result_type = uint32_t; static constexpr result_type min() { return std::numeric_limits<result_type>::min(); } static constexpr result_type max() { return std::numeric_limits<result_type>::max(); } xrand(uint64_t k) : x(k) {} xrand() : xrand(1) {} result_type operator()() { x ^= x << 9; x ^= x >> 7; return (x * 0x123456789abcdef) >> 32; } }; xrand rng; std::uniform_int_distribution<> dist4(0, 3), dist14(0, 13); constexpr std::array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1}; constexpr int N = 3000, T = 400; std::array<int, N> A, B, C, D; std::array<int, 26001> income; std::array<int, 14 * 14 * 14 * 14> cost; bool in_grid(unsigned x, unsigned y) { return x < 14 and y < 14; } int get_action() { return 1; int r = dist14(rng); if (r == 0) return 1; if (r == 1) return 3; return 2; } int main() { for (int i = 0; i <= 26; i++) { for (int j = 0; j <= 26000 / 223; j++) { int dist = 1000 * i + 223 * j; if (dist > 26000) break; income.at(dist) = 60 * j; } } cost.fill(26000); for (int i = 0; i < 196; i++) { cost.at(196 * i + i) = 0; } for (int x = 0; x < 14; x++) { for (int y = 0; y < 14; y++) { for (int dir = 0; dir < 4; dir++) { int z = x + dx[dir], w = y + dy[dir]; if (not in_grid(z, w)) continue; cost.at(196 * (14 * x + y) + (14 * z + w)) = 1000; } } } for (int k = 0; k < 196; k++) { for (int i = 0; i < 196; i++) { for (int j = 0; j < 196; j++) { cost.at(196 * i + j) = std::min(cost.at(196 * i + j), cost.at(196 * i + k) + cost.at(196 * k + j)); } } } int n, t; std::cin >> n >> t; for (int i = 0; i < N; i++) { std::cin >> A.at(i) >> B.at(i) >> C.at(i) >> D.at(i); A.at(i)--; B.at(i)--; C.at(i)--; D.at(i)--; } int64_t money = 1000000, collaborator = 1; for (int turn = 0; turn < T; turn++) { int64_t u, v; std::cin >> u >> v; assert(u == money); assert(v == collaborator); if (u == -1 and v == -1) { return 0; } int action = get_action(); int64_t d = 10000000 / sqrt(collaborator); assert(d * d * collaborator <= 100000000000000); assert((d + 1) * (d + 1) * collaborator > 100000000000000); if (money < d) action = 2; int dir, x, y, z, w; do { dir = dist4(rng); x = dist14(rng); y = dist14(rng); z = x + dx[dir]; w = y + dy[dir]; } while (not in_grid(z, w) or cost.at(196 * (14 * x + y) + (14 * z + w)) != 1000); if (action == 1) { std::cout << action << ' ' << x + 1 << ' ' << y + 1 << ' ' << z + 1 << ' ' << w + 1 << std::endl; } else { std::cout << action << std::endl; } if (action == 1) { money -= d; if (money < 0) { money = -1; collaborator = -1; continue; } cost.at(196 * (14 * x + y) + (14 * z + w)) = 223; cost.at(196 * (14 * z + w) + (14 * x + y)) = 223; for (int k = 0; k < 196; k++) { for (int i = 0; i < 196; i++) { for (int j = 0; j < 196; j++) { cost.at(196 * i + j) = std::min( cost.at(196 * i + j), cost.at(196 * i + k) + cost.at(196 * k + j)); } } } } else if (action == 2) { collaborator++; } else { money += 50000; } for (int i = 0; i < N; i++) { money += income.at(cost.at(196 * (14 * A.at(i) + B.at(i)) + (14 * C.at(i) + D.at(i)))); } } return 0; }