結果

問題 No.5016 Worst Mayor
ユーザー assy1028assy1028
提出日時 2023-04-29 14:19:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 3,485 bytes
コンパイル時間 2,749 ms
コンパイル使用メモリ 130,556 KB
実行使用メモリ 24,228 KB
スコア 7,645,094,949
平均クエリ数 400.00
最終ジャッジ日時 2023-04-29 14:19:32
合計ジャッジ時間 9,822 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
23,844 KB
testcase_01 AC 86 ms
24,192 KB
testcase_02 AC 87 ms
23,856 KB
testcase_03 AC 87 ms
23,244 KB
testcase_04 AC 87 ms
23,388 KB
testcase_05 AC 87 ms
24,216 KB
testcase_06 AC 88 ms
24,228 KB
testcase_07 AC 87 ms
24,192 KB
testcase_08 AC 86 ms
24,192 KB
testcase_09 AC 85 ms
23,496 KB
testcase_10 AC 87 ms
23,268 KB
testcase_11 AC 86 ms
23,232 KB
testcase_12 AC 87 ms
23,472 KB
testcase_13 AC 87 ms
24,180 KB
testcase_14 AC 85 ms
23,496 KB
testcase_15 AC 87 ms
23,820 KB
testcase_16 AC 87 ms
23,496 KB
testcase_17 AC 87 ms
23,664 KB
testcase_18 AC 91 ms
23,232 KB
testcase_19 AC 88 ms
23,244 KB
testcase_20 AC 84 ms
23,472 KB
testcase_21 AC 86 ms
23,268 KB
testcase_22 AC 86 ms
24,168 KB
testcase_23 AC 86 ms
24,204 KB
testcase_24 AC 88 ms
23,244 KB
testcase_25 AC 87 ms
24,204 KB
testcase_26 AC 86 ms
23,244 KB
testcase_27 AC 87 ms
23,472 KB
testcase_28 AC 87 ms
23,664 KB
testcase_29 AC 87 ms
23,844 KB
testcase_30 AC 87 ms
23,844 KB
testcase_31 AC 86 ms
23,844 KB
testcase_32 AC 86 ms
23,232 KB
testcase_33 AC 87 ms
24,096 KB
testcase_34 AC 87 ms
23,484 KB
testcase_35 AC 86 ms
23,856 KB
testcase_36 AC 86 ms
23,376 KB
testcase_37 AC 86 ms
23,220 KB
testcase_38 AC 85 ms
23,784 KB
testcase_39 AC 84 ms
23,868 KB
testcase_40 AC 87 ms
23,208 KB
testcase_41 AC 87 ms
24,168 KB
testcase_42 AC 87 ms
23,388 KB
testcase_43 AC 86 ms
23,268 KB
testcase_44 AC 86 ms
23,280 KB
testcase_45 AC 87 ms
23,244 KB
testcase_46 AC 87 ms
23,256 KB
testcase_47 AC 86 ms
23,652 KB
testcase_48 AC 85 ms
23,832 KB
testcase_49 AC 81 ms
23,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
    size_t seed = hash<T>()(x.first);
    return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int INF = 1e9 + 9;
//const ll INF = 1e18 + 9;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const double EPS = 1e-8;
const double PI = acos(-1);

unsigned long xor128(void) {
    static unsigned long x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned long t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

// [0, k)
int rand(int k) {
    return xor128() % k;
}

// [a, b)
int rand(int a, int b) {
    return a + xor128() % (b - a);
}

int n, t;
int a[3010], b[3010], c[3010], d[3010];
const int MAX_Y = 14;
const int MAX_X = 14;

int route_count[15][15][15][15];

struct road {
    int count, x, y, z, w;
};
bool operator< (const road& r1, const road& r2) {
    return r1.count < r2.count;
}

void build(const road& r) {
    cout << "1 " << r.x+1 << " " << r.y+1 << " " << r.z+1 << " " << r.w+1 << endl; cout.flush();
}

void get_coop() {
    cout << "2" << endl; cout.flush();
}

void get_money() {
    cout << "3" << endl; cout.flush();
}

void init() {
    for (int i = 0; i < n; i++) {
        const int minY = min(a[i], c[i]);
        const int maxY = max(a[i], c[i]);
        const int minX = min(b[i], d[i]);
        const int maxX = max(b[i], d[i]);
        for (int y = minY; y <= maxY; y++) {
            for (int x = minX; x <= maxX; x++) {
                if (y < maxY) route_count[y][x][y+1][x]++;
                if (x < maxX) route_count[y][x][y][x+1]++;
            }
        }
    }
}

void solve() {
    init();
    priority_queue<road> que;
    for (int y = 0; y < MAX_Y; y++) {
        for (int x = 0; x < MAX_X; x++) {
            if (y < MAX_Y-1) que.push({route_count[y][x][y+1][x], y, x, y+1, x});
            if (x < MAX_X-1) que.push({route_count[y][x][y][x+1], y, x, y, x+1});
        }
    }

    int u, v;
    for (int iter = 0; iter < t; iter++) {
        cin >> u >> v;
        const int cost = 1e7 / sqrt(v);
        const auto& r = que.top();
        const int gain = r.count * (t-iter) * 60 * pow(0.99, iter);
        //cerr << "??? " << u << " " << v << " " << cost << " " << gain << endl;
        if (u < cost || gain < cost) {
            get_coop();
        } else {
            build(r);
            que.pop();
        }
    }
}

void input() {
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
        c[i]--;
        d[i]--;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}
0