結果

問題 No.5016 Worst Mayor
ユーザー MMRZMMRZ
提出日時 2023-04-29 14:40:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 4,307 bytes
コンパイル時間 2,514 ms
コンパイル使用メモリ 214,020 KB
実行使用メモリ 24,264 KB
スコア 1,086,749,356
平均クエリ数 400.00
最終ジャッジ日時 2023-04-29 14:40:38
合計ジャッジ時間 16,139 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 206 ms
23,652 KB
testcase_01 AC 205 ms
23,412 KB
testcase_02 AC 202 ms
24,264 KB
testcase_03 AC 200 ms
23,976 KB
testcase_04 AC 200 ms
23,952 KB
testcase_05 AC 203 ms
23,616 KB
testcase_06 AC 206 ms
24,168 KB
testcase_07 AC 202 ms
23,364 KB
testcase_08 AC 202 ms
23,916 KB
testcase_09 AC 199 ms
23,544 KB
testcase_10 AC 200 ms
23,832 KB
testcase_11 AC 202 ms
23,616 KB
testcase_12 AC 205 ms
23,412 KB
testcase_13 AC 204 ms
24,156 KB
testcase_14 AC 203 ms
23,232 KB
testcase_15 AC 205 ms
24,012 KB
testcase_16 AC 202 ms
23,652 KB
testcase_17 AC 213 ms
23,880 KB
testcase_18 AC 202 ms
23,616 KB
testcase_19 AC 203 ms
23,976 KB
testcase_20 AC 199 ms
23,412 KB
testcase_21 AC 201 ms
23,844 KB
testcase_22 AC 228 ms
23,940 KB
testcase_23 AC 202 ms
23,844 KB
testcase_24 AC 202 ms
23,520 KB
testcase_25 AC 202 ms
23,256 KB
testcase_26 AC 201 ms
23,376 KB
testcase_27 AC 232 ms
23,592 KB
testcase_28 AC 202 ms
24,000 KB
testcase_29 AC 202 ms
23,556 KB
testcase_30 AC 201 ms
23,244 KB
testcase_31 AC 204 ms
23,652 KB
testcase_32 AC 220 ms
24,000 KB
testcase_33 AC 202 ms
24,252 KB
testcase_34 AC 201 ms
23,268 KB
testcase_35 AC 197 ms
23,424 KB
testcase_36 AC 202 ms
23,256 KB
testcase_37 AC 229 ms
23,556 KB
testcase_38 AC 199 ms
23,652 KB
testcase_39 AC 204 ms
23,412 KB
testcase_40 AC 200 ms
24,180 KB
testcase_41 AC 199 ms
23,244 KB
testcase_42 AC 225 ms
23,544 KB
testcase_43 AC 201 ms
23,844 KB
testcase_44 AC 201 ms
23,268 KB
testcase_45 AC 201 ms
23,976 KB
testcase_46 AC 202 ms
23,940 KB
testcase_47 AC 201 ms
24,048 KB
testcase_48 AC 202 ms
23,376 KB
testcase_49 AC 201 ms
23,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# include "bits/stdc++.h"
using namespace std;
using LL = long long;
# define all(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define rep(i,upupu)         for(int i = 0, i##_len = (upupu);(i) < (i##_len);(i)++)

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#ifdef LOCAL
#  include "_debug_print.hpp"
#  define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define debug(...) (static_cast<void>(0))
#endif

const double TIME_LIMIT = 2000.0;

struct plan {
    int order;
    int x, y, z, w;
};

const int n = 3000, t = 400, w = 14;
int a[n], b[n], c[n], d[n];

struct KYOPRO_dist {
    int normal_cnt = 0, highway_cnt = 0;

    bool operator<( const KYOPRO_dist& right ) const {
        return double(normal_cnt) + 0.223 * highway_cnt < double(right.normal_cnt) + 0.223 * right.highway_cnt;
    }
};

vector<plan> solve(){
    vector<plan> ans(t);
    rep(i, 20)ans[i].order = 2;
    for(int i = 20;i < 45;i++)ans[i].order = 3;

    vector<vector<KYOPRO_dist>> dist(w * w, vector<KYOPRO_dist>(w * w));
    rep(i, w * w)rep(j, w * w){
        dist[i][j].normal_cnt = (abs(i % w - j % w) + abs(i / w + j / w));
    }

    int day = 45;
    {
        ans[day].order = 1;

        int max_c = 0, max_type = -1, mi = -1, mj = -1;

        { // tate
            rep(i, 13)rep(j, 14){
                auto tmp_dist = dist;

                int s = i * w + j;
                int t = (i + 1) * w + j;

                tmp_dist[s][t] = tmp_dist[t][s] = min(tmp_dist[s][t], KYOPRO_dist{tmp_dist[s][t].normal_cnt - 1, tmp_dist[s][t].highway_cnt + 1});

                for(int k : {s, t}){
                    rep(row, w * w)rep(column, w * w){
                        tmp_dist[row][column] = min(tmp_dist[row][column], KYOPRO_dist{tmp_dist[row][k].normal_cnt + tmp_dist[k][column].normal_cnt, tmp_dist[row][k].highway_cnt + tmp_dist[k][column].highway_cnt});
                    }
                }

                int cnt_c = 0;

                rep(x, n){
                    cnt_c += tmp_dist[a[i] * w + b[i]][c[i] * w + d[i]].highway_cnt;
                }

                if(max_c < cnt_c){
                    max_c = cnt_c;
                    max_type = 0;
                    mi = i, mj = j;
                }
            }
        }

        { // yoko
            rep(i, 14)rep(j, 13){
                auto tmp_dist = dist;

                int s = i * w + j;
                int t = i * w + j + 1;

                tmp_dist[s][t] = tmp_dist[t][s] = min(tmp_dist[s][t], KYOPRO_dist{tmp_dist[s][t].normal_cnt - 1, tmp_dist[s][t].highway_cnt + 1});

                for(int k : {s, t}){
                    rep(row, w * w)rep(column, w * w){
                        tmp_dist[row][column] = min(tmp_dist[row][column], KYOPRO_dist{tmp_dist[row][k].normal_cnt + tmp_dist[k][column].normal_cnt, tmp_dist[row][k].highway_cnt + tmp_dist[k][column].highway_cnt});
                    }
                }

                int cnt_c = 0;

                rep(x, n){
                    cnt_c += tmp_dist[a[i] * w + b[i]][c[i] * w + d[i]].highway_cnt;
                }

                if(max_c < cnt_c){
                    max_c = cnt_c;
                    max_type = 1;
                    mi = i, mj = j;
                }
            }
        }

        if(max_c > 0){
            ans[day].x = mi, ans[day].y = mj;
            ans[day].z = mi + (max_type == 0), ans[day].w = mj + (max_type == 1);
        }else{
            ans[day].order = 3;
        }
    }

    for(int i = 46;i < t;i++)ans[i].order = 3;

    return ans;
}

void input(){
    int _n, _t; cin >> _n >> _t;
    rep(i, n){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--, c[i]--, d[i]--;
    }
    return;
}

void output(vector<plan> ans){
    
    LL buf;

    rep(i, t){

        if(i)cin >> buf >> buf;

        if(ans[i].order != 1){
            cout << ans[i].order << endl;
            cout.flush();
        }else{
            cout << "1 " << ans[i].x + 1 << " " << ans[i].y + 1 << " " << ans[i].z + 1 << " " << ans[i].w + 1 << endl;
            cout.flush();
        }
    }
}

int main(){
    input();
    auto f = solve();
    output(f);
}
0