結果
問題 | No.5016 Worst Mayor |
ユーザー | trineutron |
提出日時 | 2023-04-29 10:57:27 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 442 ms / 2,000 ms |
コード長 | 4,583 bytes |
コンパイル時間 | 913 ms |
コンパイル使用メモリ | 83,172 KB |
実行使用メモリ | 24,360 KB |
スコア | 19,151,047,561 |
平均クエリ数 | 400.00 |
最終ジャッジ日時 | 2023-04-29 12:39:01 |
合計ジャッジ時間 | 23,817 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 392 ms
23,436 KB |
testcase_01 | AC | 348 ms
24,336 KB |
testcase_02 | AC | 407 ms
24,012 KB |
testcase_03 | AC | 392 ms
23,388 KB |
testcase_04 | AC | 400 ms
24,360 KB |
testcase_05 | AC | 400 ms
23,340 KB |
testcase_06 | AC | 365 ms
23,496 KB |
testcase_07 | AC | 399 ms
24,336 KB |
testcase_08 | AC | 430 ms
24,300 KB |
testcase_09 | AC | 426 ms
24,336 KB |
testcase_10 | AC | 386 ms
23,376 KB |
testcase_11 | AC | 373 ms
23,328 KB |
testcase_12 | AC | 400 ms
23,580 KB |
testcase_13 | AC | 375 ms
23,544 KB |
testcase_14 | AC | 398 ms
24,204 KB |
testcase_15 | AC | 396 ms
24,012 KB |
testcase_16 | AC | 398 ms
23,340 KB |
testcase_17 | AC | 376 ms
23,976 KB |
testcase_18 | AC | 408 ms
23,844 KB |
testcase_19 | AC | 385 ms
24,000 KB |
testcase_20 | AC | 415 ms
23,580 KB |
testcase_21 | AC | 395 ms
23,400 KB |
testcase_22 | AC | 403 ms
23,628 KB |
testcase_23 | AC | 441 ms
23,964 KB |
testcase_24 | AC | 411 ms
24,324 KB |
testcase_25 | AC | 370 ms
23,580 KB |
testcase_26 | AC | 361 ms
23,988 KB |
testcase_27 | AC | 406 ms
23,628 KB |
testcase_28 | AC | 391 ms
23,784 KB |
testcase_29 | AC | 407 ms
23,652 KB |
testcase_30 | AC | 363 ms
24,336 KB |
testcase_31 | AC | 372 ms
23,988 KB |
testcase_32 | AC | 405 ms
24,012 KB |
testcase_33 | AC | 409 ms
23,616 KB |
testcase_34 | AC | 391 ms
23,496 KB |
testcase_35 | AC | 442 ms
23,616 KB |
testcase_36 | AC | 407 ms
23,604 KB |
testcase_37 | AC | 382 ms
23,436 KB |
testcase_38 | AC | 407 ms
23,988 KB |
testcase_39 | AC | 384 ms
23,976 KB |
testcase_40 | AC | 371 ms
23,652 KB |
testcase_41 | AC | 401 ms
24,216 KB |
testcase_42 | AC | 387 ms
23,616 KB |
testcase_43 | AC | 424 ms
24,024 KB |
testcase_44 | AC | 377 ms
23,388 KB |
testcase_45 | AC | 379 ms
23,844 KB |
testcase_46 | AC | 397 ms
23,364 KB |
testcase_47 | AC | 349 ms
23,412 KB |
testcase_48 | AC | 368 ms
23,412 KB |
testcase_49 | AC | 399 ms
23,628 KB |
ソースコード
#include <array> #include <cassert> #include <cmath> #include <iostream> 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; constexpr bool in_grid(unsigned x, unsigned y) { return x < 14 and y < 14; } constexpr int id(unsigned x, unsigned y) { return 14 * x + y; } constexpr int id4(unsigned x, unsigned y, unsigned z, unsigned w) { return 2744 * x + 196 * y + 14 * z + w; } int main() { 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)--; } 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; } } for (int x = 0; x < 14; x++) { for (int y = 0; y < 14; y++) { for (int z = 0; z < 14; z++) { for (int w = 0; w < 14; w++) { cost.at(id4(x, y, z, w)) = 1000 * (abs(x - z) + abs(y - w)); } } } } int64_t income_turn = 0, income_next = 0; int x, y, z, w; auto road_next = [&]() { for (int i = 0; i < 14; i++) { for (int j = 0; j < 14; j++) { for (int dir = 0; dir < 2; dir++) { int k = i + dx[dir], l = j + dy[dir]; if (not in_grid(k, l)) continue; if (cost.at(id4(i, j, k, l)) != 1000) continue; int count = 0; for (int person = 0; person < N; person++) { int a = A.at(person), b = B.at(person), c = C.at(person), d = D.at(person); int distance = cost.at(id4(a, b, c, d)); distance = std::min(distance, cost.at(id4(a, b, i, j)) + 223 + cost.at(id4(k, l, c, d))); distance = std::min(distance, cost.at(id4(a, b, k, l)) + 223 + cost.at(id4(i, j, c, d))); count += income.at(distance); } if (count > income_next) { income_next = count; x = i; y = j; z = k; w = l; } } } } }; road_next(); 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; } int64_t d = 10000000 / sqrt(collaborator); assert(d * d * collaborator <= 100000000000000); assert((d + 1) * (d + 1) * collaborator > 100000000000000); int action = 1; if (turn < 21) { action = 2; } else if (money < d or (income_next - income_turn) * (T - turn) < d + 50000) { action = 3; } 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; } int k = id(x, y), l = id(z, w); 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) + 223 + cost.at(196 * l + j)); cost.at(196 * i + j) = std::min( cost.at(196 * i + j), cost.at(196 * i + l) + 223 + cost.at(196 * k + j)); } } income_turn = income_next; road_next(); } else if (action == 2) { collaborator++; } else { money += 50000; } money += income_turn; } return 0; }