結果

問題 No.5013 セクスタプル (open)
ユーザー 3mEhsfd8aG5jx2t
提出日時 2022-12-29 14:19:33
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,439 bytes
コンパイル時間 2,268 ms
実行使用メモリ 5,164 KB
スコア 7,779
最終ジャッジ日時 2022-12-29 14:19:42
合計ジャッジ時間 6,940 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
struct Input {
  array<array<int, 7>, 36> in;
  Input() {
    REP(i, 36) {
      REP(j, 6) {
        cin >> in[i][j];
        in[i][j]--;
      }
      in[i][6] = i;
    }
  }
  array<int, 6> CheckCount() {
    // 残っているダイスの数を数える
    array<int, 6> ret;
    REP(i, 36) {
      if(in[i][0] == -1)continue;
      REP(j, 6) {
        ret[in[i][j]]++;
      }
    }
    return ret;
  }
  int SearchTarget() {
    //並べる数を探す
    array<int, 6> ss = CheckCount();
    int ret = 0;
    REP(i, 6) {
      if(ss[ret] < ss[i]) {
        ret = i;
      }
    }
    return ret;
  }
  void Solve() {
    array<pair<int, int>, 36> ans;
    REP(i, 6) {
      const int TARGET = SearchTarget();
      sort(in.begin(), in.end(), [&](auto l, auto r) {
        if(l[0] == -1)return false;
      if(r[0] == -1)return true;
      auto f = [&](array<int, 7> arr) {
        int ret = 0;
        REP(i, 6) {
          if(arr[i] == TARGET)ret++;
        }
        return ret;
      };
      int lcount = f(l), rcount = f(r);
      return lcount > rcount;
        });
      REP(j, 6) {
        ans[in[j][6]] = pair<int, int>(i + 1, j + 1);
        in[j][0] = -1;
      }
    }
    REP(i, 36) {
      cout << ans[i].first << " " << ans[i].second << endl;
    }
  }
};
int main() {
  Input in;
  in.Solve();
}
0