結果

問題 No.5014 セクスタプル (reactive)
ユーザー NAMIDAIRONAMIDAIRO
提出日時 2022-12-29 19:57:38
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 2,437 bytes
コンパイル時間 3,450 ms
実行使用メモリ 22,864 KB
スコア 590,745,959
平均クエリ数 35.00
最終ジャッジ日時 2022-12-29 19:58:05
合計ジャッジ時間 8,602 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <ctime>
#include <random>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)

template<class T>
using vi = vector<T>;

template<class T>
using vii = vector<vi<T>>;

template<class T>
using viii = vector<vii<T>>;

using pii = pair<int, int>;

int n = 36;
const int len = 6;
const int TL = 1 * 1000;
const int TL2 = 2 * 1000;
const int inf = 1e9;

struct dice {
    vi<int> vec;
    int idx = 0;
    dice() : vec(len), idx(0) {}
};

vi<dice> d(n);
vii<int> board(len, vi<int>(len));

int score() {
    const int inf = 1e9;
    int res = 0;
    rep(i, len) {
        vi<int> cnt(len, 0);
        rep(j, len) {
            rep(k, len) { //どの値
                int pos = board[i][j];
                int num = d[pos].vec[k];
                if (num) cnt[k] += num;
                else cnt[k] = -inf;
            }
        }

        rep(k, len) {
            if (cnt[k] > 0) res += 3 + cnt[k] - 6;
        }
    }

    rep(j, len) {
        vi<int> cnt(len, 0);
        rep(i, len) {
            rep(k, len) { //どの値
                int pos = board[i][j];
                int num = d[pos].vec[k];
                if (num) cnt[k] += num;
                else cnt[k] = -inf;
            }
        }

        rep(k, len) {
            if (cnt[k] > 0) res += 3 + cnt[k] - 6;
        }
    }

    return res * 1000;
}

void inv() {
    rep(i, len) rep(j, i) {
        swap(board[i][j], board[j][i]);
    }
    return;
}

int main()
{
    random_device rnd;
    clock_t start = clock();

    rep(i, n) rep(k, len) d[i].vec[k] = 1;
    rep(i, len) rep(j, len) board[i][j] = n - 1;

    int scr = 0;
    vi<bool> used(n);
    rep(i, n - 1) {
        rep(j, len) d[i].vec[j] = 0;

        rep(j, len) {
            int t;
            cin >> t;
            t--;
            d[i].vec[t]++;
        }

        int pos = -1;
        scr = -inf;
        rep(j, n) {
            if (used[j]) continue;
            board[j / len][j % len] = i;
            int ts = score();
            if (ts > scr) {
                scr = ts;
                pos = j;
            }
            board[j / len][j % len] = n - 1;
        }
        used[pos] = true;
        board[pos / len][pos % len] = i;
        cout << pos / len + 1 << " " << pos % len + 1 << endl;
    }


    return 0;
}
0