結果

問題 No.452 横着者のビンゴゲーム
ユーザー hanorverhanorver
提出日時 2016-12-03 01:27:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,115 bytes
コンパイル時間 987 ms
コンパイル使用メモリ 90,156 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-05-05 17:20:42
合計ジャッジ時間 17,921 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 6 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 708 ms
7,424 KB
testcase_15 AC 691 ms
7,296 KB
testcase_16 AC 374 ms
5,632 KB
testcase_17 AC 26 ms
5,376 KB
testcase_18 AC 173 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 59 ms
5,376 KB
testcase_21 AC 499 ms
5,376 KB
testcase_22 AC 42 ms
5,376 KB
testcase_23 AC 952 ms
5,376 KB
testcase_24 AC 34 ms
5,376 KB
testcase_25 AC 19 ms
5,376 KB
testcase_26 AC 488 ms
5,376 KB
testcase_27 AC 245 ms
5,376 KB
testcase_28 AC 199 ms
5,376 KB
testcase_29 AC 92 ms
5,376 KB
testcase_30 AC 623 ms
5,376 KB
testcase_31 AC 68 ms
5,376 KB
testcase_32 AC 38 ms
5,376 KB
testcase_33 AC 176 ms
5,376 KB
testcase_34 AC 179 ms
5,376 KB
testcase_35 AC 113 ms
5,376 KB
testcase_36 AC 25 ms
5,376 KB
testcase_37 AC 25 ms
5,376 KB
testcase_38 AC 2,409 ms
6,784 KB
testcase_39 AC 1,516 ms
5,504 KB
testcase_40 AC 1,471 ms
5,632 KB
testcase_41 AC 1,477 ms
5,504 KB
testcase_42 AC 1,480 ms
5,504 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

int main() {
    // 基本的には辺の長さで良い
    // しかし、そのときにビンゴになるのが2つ以上あれば辺の長さ-1
    int n, m;

    std::cin >> n >> m;

    std::vector<std::vector<int> > bingo(n, std::vector<int>(n));
    // i人目のj個目のビンゴのになる数値の要素
    std::vector<std::vector<std::set<int> > > v(m);

    for (int k = 0; k < m; k++) {
        std::set<int> s;
        for (int i = 0; i < n * n; i++) {
            std::cin >> bingo[i / n][i % n];
            s.insert(bingo[i / n][i % n]);
            if (i != 0 && i % n == 0) {
                v[k].push_back(s);
                s.clear();
            }
        }
        v[k].push_back(s);
        // 縦のビンゴを見る
        for (int i = 0; i < n; i++) {
            s.clear();
            for (int j = 0; j < n; j++) {
                s.insert(bingo[j][i]);
            }
            v[k].push_back(s);
        }
        v[k].push_back(s);
        s.clear();
        // 斜めのビンゴ
        for (int i = 0; i < n; i++) {
            s.insert(bingo[i][i]);
        }
        v[k].push_back(s);
        s.clear();
        for (int i = 0; i < n; i++) {
            s.insert(bingo[i][n - i - 1]);
        }
        v[k].push_back(s);
    }
    // 一致率を求める
    int max_match = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < v[i].size(); j++) {
            for (int k = 0; k < m; k++) {
                if (i == k) continue;
                for (int l = 0; l < v[k].size(); l++) {
                    int n_match = 0;
                    for (auto it = v[i][j].begin(); it != v[i][j].end(); it++) {
                        if (v[k][l].find(*it) != v[k][l].end()) {
                            n_match++;
                        }
                    }
                    max_match = std::max(max_match, n_match);
                }
            }
        }
    }

    int ans = std::max(n + (n - (max_match + 1)), 1);

    std::cout << ans << std::endl;

    return 0;
}
0