結果

問題 No.5016 Worst Mayor
ユーザー a9ua1i0na9ua1i0n
提出日時 2023-04-29 16:27:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,298 bytes
コンパイル時間 3,953 ms
コンパイル使用メモリ 226,908 KB
実行使用メモリ 24,540 KB
スコア 0
平均クエリ数 400.00
最終ジャッジ日時 2023-04-29 16:28:03
合計ジャッジ時間 9,542 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
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 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
権限があれば一括ダウンロードができます

ソースコード

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 {
            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