結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 4 ms
5,376 KB
testcase_23 WA -
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    std::cin >> n >> m;

    int ans = n;

    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);
    }

    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++) {
                    if (v[i][j] == v[k][l]) {
                        std::cout << n - 1 << std::endl;
                        return 0;
                    }
                }
            }
        }
    }

    std::cout << n << std::endl;

    return 0;
}
0