結果
| 問題 | No.5016 Worst Mayor | 
| コンテスト | |
| ユーザー |  tempura_pp | 
| 提出日時 | 2023-04-29 14:21:21 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 628 ms / 2,000 ms | 
| コード長 | 3,910 bytes | 
| コンパイル時間 | 1,622 ms | 
| コンパイル使用メモリ | 139,840 KB | 
| 実行使用メモリ | 24,324 KB | 
| スコア | 20,516,409,514 | 
| 平均クエリ数 | 400.00 | 
| 最終ジャッジ日時 | 2023-04-29 14:21:59 | 
| 合計ジャッジ時間 | 36,985 ms | 
| ジャッジサーバーID (参考情報) | judge12 / judge11 | 
| 純コード判定しない問題か言語 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 50 | 
ソースコード
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using ll = long long;
constexpr int inf = 1e9 + 7;
constexpr ll longinf = 1LL << 60;
constexpr ll mod = 1e9 + 7;
struct Xor128 {
    unsigned x, y, z, w;
    Xor128(unsigned w_ = 88675123) : x(123456789), y(362436069), z(521288629), w(w_){};
    inline unsigned xor128() {
        unsigned t;
        t = x ^ (x << 11);
        x = y;
        y = z;
        z = w;
        return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    }
    int nextInt(int x, int y) {
        if(x > y)
            swap(x, y);
        return xor128() % (y - x) + x;
    }
    double nextDouble(double a, double b) {
        return (double)(xor128() & 0xffff) / 0xffff * (b - a) + a;
    }
};
int dist[200][200];
int N = 3000, T = 400, M = 196;
int cost[3030];
int s[3030], t[3030];
int NC = 100000, NH = 22301;
int if_update(int v1, int v2) {
    int res = 0;
    rep(i, N) {
        int nc = min(dist[s[i]][t[i]], min(dist[s[i]][v1] + dist[v2][t[i]] + NH, dist[s[i]][v2] + dist[v1][t[i]] + NH));
        res += nc % 100;
    }
    return res;
}
void update(int v1, int v2) {
    dist[v1][v2] = NH;
    dist[v2][v1] = NH;
    rep(i, M) rep(j, M) {
        dist[i][j] = min(dist[i][j], min(dist[i][v1] + dist[v2][j] + NH, dist[i][v2] + dist[v1][j] + NH));
    }
}
void input() {
    int _;
    cin >> _ >> _;
    rep(i, N) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        --a;
        --b;
        --c;
        --d;
        s[i] = a * 14 + b;
        t[i] = c * 14 + d;
    }
    rep(i, 200) rep(j, 200) {
        dist[i][j] = NC * 50;
    }
    rep(i, 14) rep(j, 14) {
        int x = i * 14 + j;
        if(j > 0) {
            dist[x][x - 1] = NC;
        }
        if(j < 13) {
            dist[x][x + 1] = NC;
        }
        if(i > 0) {
            dist[x][x - 14] = NC;
        }
        if(i < 13) {
            dist[x][x + 14] = NC;
        }
        dist[x][x] = 0;
    }
    rep(i, M) rep(j, M) rep(k, M) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
}
int num = 0;
void output(int x, int y) {
    cout << 1 << " ";
    cout << x / 14 + 1 << " " << x % 14 + 1 << " ";
    cout << y / 14 + 1 << " " << y % 14 + 1 << endl;
    ++num;
}
auto rng = Xor128();
int cur = 0;
int U = 1000000, V = 1;
pair<int, int> read() {
    // cerr << cur << " " << U << " " << V << endl;
    // return {U, V};
    int u, v;
    cin >> u >> v;
    return {u, v};
}
void turn(int t) {
    auto p = read();
    int u = p.first, v = p.second;
    int ma = 0, mx = 0, my = 0;
    rep(_, 100) {
        int e = rng.nextInt(0, 2 * 14 * 13);
        int x, y;
        if(e < 13 * 14) {
            x = (e / 13) * 14 + e % 13;
            y = x + 1;
        } else {
            e -= 13 * 14;
            x = e;
            y = e + 14;
        }
        int res = if_update(x, y);
        if(res > ma) {
            ma = res, mx = x, my = y;
        }
    }
    int ben = 60 * (ma - cur) * (T - t);
    int pay = (int)(10000000 / sqrt(v));
    if(ben > pay && u > pay) {
        output(mx, my);
        update(mx, my);
        cur = ma;
        U = u - pay;
    } else {
        int npay = (int)(10000000 / sqrt(v + 1));
        int dpay = max(1, min(40 - num, T - t)) * (pay - npay);
        if(dpay > 50000) {
            cout << 2 << endl;
            V = v + 1;
        } else {
            cout << 3 << endl;
            U = u + 50000;
        }
    }
    U += cur * 60;
}
int main() {
    input();
    rep(i, T) {
        turn(i);
    }
    cerr << U << " " << V << endl;
    return 0;
}
            
            
            
        