結果

問題 No.5016 Worst Mayor
ユーザー a9ua1i0na9ua1i0n
提出日時 2023-04-29 16:34:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,404 ms / 2,000 ms
コード長 4,315 bytes
コンパイル時間 2,783 ms
コンパイル使用メモリ 225,316 KB
実行使用メモリ 24,312 KB
スコア 1,520,581,860
平均クエリ数 400.00
最終ジャッジ日時 2023-04-29 16:35:20
合計ジャッジ時間 59,109 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 664 ms
23,976 KB
testcase_01 AC 1,299 ms
23,652 KB
testcase_02 AC 939 ms
23,280 KB
testcase_03 AC 892 ms
23,592 KB
testcase_04 AC 1,028 ms
24,228 KB
testcase_05 AC 994 ms
23,976 KB
testcase_06 AC 1,161 ms
23,532 KB
testcase_07 AC 912 ms
24,312 KB
testcase_08 AC 1,103 ms
23,520 KB
testcase_09 AC 1,061 ms
23,700 KB
testcase_10 AC 716 ms
24,216 KB
testcase_11 AC 829 ms
23,508 KB
testcase_12 AC 1,226 ms
23,400 KB
testcase_13 AC 1,187 ms
23,268 KB
testcase_14 AC 950 ms
23,424 KB
testcase_15 AC 531 ms
23,496 KB
testcase_16 AC 689 ms
23,892 KB
testcase_17 AC 1,404 ms
23,532 KB
testcase_18 AC 1,040 ms
23,496 KB
testcase_19 AC 1,279 ms
23,916 KB
testcase_20 AC 1,293 ms
23,412 KB
testcase_21 AC 1,286 ms
23,988 KB
testcase_22 AC 922 ms
23,292 KB
testcase_23 AC 1,155 ms
23,508 KB
testcase_24 AC 884 ms
23,376 KB
testcase_25 AC 1,089 ms
23,520 KB
testcase_26 AC 978 ms
23,712 KB
testcase_27 AC 1,262 ms
23,820 KB
testcase_28 AC 1,354 ms
24,132 KB
testcase_29 AC 898 ms
23,976 KB
testcase_30 AC 1,389 ms
23,916 KB
testcase_31 AC 1,116 ms
23,916 KB
testcase_32 AC 977 ms
24,192 KB
testcase_33 AC 790 ms
23,700 KB
testcase_34 AC 634 ms
23,904 KB
testcase_35 AC 930 ms
23,412 KB
testcase_36 AC 844 ms
23,988 KB
testcase_37 AC 1,001 ms
23,916 KB
testcase_38 AC 1,208 ms
23,412 KB
testcase_39 AC 1,085 ms
23,280 KB
testcase_40 AC 1,102 ms
23,628 KB
testcase_41 AC 1,061 ms
23,988 KB
testcase_42 AC 1,180 ms
24,228 KB
testcase_43 AC 1,223 ms
23,388 KB
testcase_44 AC 1,058 ms
23,532 KB
testcase_45 AC 836 ms
23,388 KB
testcase_46 AC 879 ms
23,400 KB
testcase_47 AC 1,240 ms
23,904 KB
testcase_48 AC 958 ms
24,228 KB
testcase_49 AC 1,030 ms
23,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define REPITR(itr, ARRAY) for (auto itr = (ARRAY).begin(); itr != (ARRAY).end(); ++itr)
#define RREPITR(itr, ARRAY) for (auto itr = (ARRAY).rbegin(); itr != (ARRAY).rend(); ++itr)
#define ALL(n) (n).begin(), (n).end()
using ll = long long;
using ull = unsigned long long;
// #define int long long
template<typename T>
struct edge {
    int to;
    T cost;
    edge() {}
    edge(int to, T cost):
        to(to), cost(cost) {}
};

ll N; // 3000 fixed
ll T; // 400 fixed
vector<pair<pair<int, int>, pair<int, int>>> working_pathes;
ll money = 1e6;
ll constexpr cost_base = 1e7;
ll collaborater = 1;
ll constexpr grid_size = 14;
pair<int, int> dir[4] = {pair<int, int>(0, 1), pair<int, int>(0, -1), pair<int, int>(1, 0), pair<int, int>(-1, 0)};
set<pair<pair<int, int>, pair<int, int>>> is_constructed;

signed main() {
    cin >> N >> T;
    working_pathes.resize(N);
    REP(i, N) {
        cin >> working_pathes[i].first.first
            >> working_pathes[i].first.second
            >> working_pathes[i].second.first
            >> working_pathes[i].second.second;
        working_pathes[i].first.first--;
        working_pathes[i].first.second--;
        working_pathes[i].second.first--;
        working_pathes[i].second.second--;
    }
    clock_t start_time = clock();
    map<pair<pair<int, int>, pair<int, int>>, int> seen_count;
    int rem = 0;

    REP(_never_use_this_variable, T) {
        if (clock() - start_time > 1.8 * CLOCKS_PER_SEC) {
            cout << 3 << endl;
            continue;
        }
        cin >> money >> collaborater;

        if (collaborater < 100) {
            cout << 2 << endl;
            continue;
        } else if (money < cost_base / sqrt(collaborater)) {
            cout << 3 << endl;
            continue;
        } else {
            rem--;
            if (rem < 0) {
                rem = 5;
                seen_count.clear();
                REP(n, N) {
                    pair<int, int> start = working_pathes[n].first;
                    pair<int, int> end = working_pathes[n].second;

                    vector<vector<bool>> seen(grid_size, vector<bool>(grid_size));
                    deque<pair<int, int>> que;
                    que.push_back(start);
                    seen[start.first][start.second] = true;
                    while (!que.empty()) {
                        pair<int, int> c = que.front();
                        que.pop_front();
                        if (c == end) {
                            break;
                        }

                        for (auto d: dir) {
                            auto n = c;
                            n.first += d.first;
                            n.second += d.second;

                            if (n.first < 0 || grid_size <= n.first || n.second < 0 || grid_size <= n.second) {
                                continue;
                            }

                            auto path = pair<pair<int, int>, pair<int, int>>(c, n);

                            if (seen[n.first][n.second]) {
                                continue;
                            }

                            bool exsits = is_constructed.find(path) != is_constructed.end();
                            if (!exsits) {
                                seen_count[path] += 1;
                            }

                            seen[n.first][n.second] = true;

                            if (exsits) {
                                que.push_front(n);
                            } else {
                                que.push_back(n);
                            }
                        }
                    }
                }
            }
            auto ma = max_element(ALL(seen_count), [](const auto& x, const auto& y) {
                return x.second < y.second;
            });
            cout << 1 << " "
                 << (*ma).first.first.first + 1 << " " << (*ma).first.first.second + 1 << " "
                 << (*ma).first.second.first + 1 << " " << (*ma).first.second.second + 1 << endl;
            is_constructed.insert((*ma).first);
            (*ma).second = -1;
        }
    }

    return 0;
}
0