結果

問題 No.5016 Worst Mayor
ユーザー a9ua1i0na9ua1i0n
提出日時 2023-04-29 16:17:17
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,666 ms / 2,000 ms
コード長 3,714 bytes
コンパイル時間 3,757 ms
コンパイル使用メモリ 171,592 KB
実行使用メモリ 24,336 KB
スコア 963,607,560
平均クエリ数 400.00
最終ジャッジ日時 2023-04-29 16:18:49
合計ジャッジ時間 86,931 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,613 ms
24,336 KB
testcase_01 AC 1,607 ms
23,532 KB
testcase_02 AC 1,638 ms
23,544 KB
testcase_03 AC 1,656 ms
23,556 KB
testcase_04 AC 1,628 ms
24,072 KB
testcase_05 AC 1,630 ms
24,072 KB
testcase_06 AC 1,484 ms
23,400 KB
testcase_07 AC 1,598 ms
23,616 KB
testcase_08 AC 1,625 ms
23,976 KB
testcase_09 AC 1,652 ms
23,532 KB
testcase_10 AC 1,618 ms
24,252 KB
testcase_11 AC 1,553 ms
23,820 KB
testcase_12 AC 1,626 ms
24,048 KB
testcase_13 AC 1,126 ms
23,652 KB
testcase_14 AC 1,632 ms
23,400 KB
testcase_15 AC 1,647 ms
23,676 KB
testcase_16 AC 1,624 ms
23,412 KB
testcase_17 AC 1,599 ms
23,532 KB
testcase_18 AC 1,615 ms
23,376 KB
testcase_19 AC 1,642 ms
23,532 KB
testcase_20 AC 1,632 ms
24,240 KB
testcase_21 AC 1,624 ms
23,988 KB
testcase_22 AC 1,633 ms
23,532 KB
testcase_23 AC 1,630 ms
24,084 KB
testcase_24 AC 1,597 ms
23,436 KB
testcase_25 AC 1,631 ms
24,000 KB
testcase_26 AC 1,629 ms
24,300 KB
testcase_27 AC 1,637 ms
24,192 KB
testcase_28 AC 1,642 ms
24,096 KB
testcase_29 AC 1,625 ms
23,412 KB
testcase_30 AC 1,557 ms
23,568 KB
testcase_31 AC 1,635 ms
24,192 KB
testcase_32 AC 1,620 ms
23,376 KB
testcase_33 AC 1,644 ms
23,844 KB
testcase_34 AC 1,666 ms
23,616 KB
testcase_35 AC 1,647 ms
24,084 KB
testcase_36 AC 1,347 ms
24,084 KB
testcase_37 AC 1,617 ms
23,412 KB
testcase_38 AC 1,288 ms
24,000 KB
testcase_39 AC 1,647 ms
23,532 KB
testcase_40 AC 1,599 ms
23,400 KB
testcase_41 AC 1,597 ms
23,436 KB
testcase_42 AC 1,614 ms
24,180 KB
testcase_43 AC 1,635 ms
23,868 KB
testcase_44 AC 1,624 ms
23,532 KB
testcase_45 AC 1,637 ms
24,084 KB
testcase_46 AC 1,605 ms
23,580 KB
testcase_47 AC 1,036 ms
24,060 KB
testcase_48 AC 1,638 ms
23,616 KB
testcase_49 AC 1,638 ms
23,376 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();

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

        if (collaborater < 100) {
            cout << 2 << endl;
            continue;
        }
        if (money < cost_base / sqrt(collaborater)) {
            cout << 3 << endl;
            continue;
        }

        map<pair<pair<int, int>, pair<int, int>>, int> seen_count;

        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));
        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);
    }

    return 0;
}
0