結果

問題 No.452 横着者のビンゴゲーム
ユーザー h_nosonh_noson
提出日時 2016-12-03 00:32:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,488 bytes
コンパイル時間 1,514 ms
コンパイル使用メモリ 98,124 KB
実行使用メモリ 8,216 KB
最終ジャッジ日時 2023-08-18 11:40:36
合計ジャッジ時間 31,500 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 7 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 10 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 WA -
testcase_14 AC 1,966 ms
7,472 KB
testcase_15 AC 1,882 ms
7,476 KB
testcase_16 AC 1,089 ms
5,696 KB
testcase_17 AC 107 ms
8,216 KB
testcase_18 AC 296 ms
4,380 KB
testcase_19 AC 192 ms
4,384 KB
testcase_20 AC 134 ms
6,100 KB
testcase_21 AC 760 ms
4,788 KB
testcase_22 AC 104 ms
8,140 KB
testcase_23 AC 1,407 ms
5,408 KB
testcase_24 WA -
testcase_25 AC 43 ms
5,912 KB
testcase_26 AC 818 ms
4,676 KB
testcase_27 AC 518 ms
4,524 KB
testcase_28 AC 335 ms
4,376 KB
testcase_29 AC 193 ms
4,380 KB
testcase_30 AC 991 ms
4,852 KB
testcase_31 AC 132 ms
4,376 KB
testcase_32 AC 86 ms
4,380 KB
testcase_33 AC 374 ms
4,376 KB
testcase_34 AC 327 ms
4,380 KB
testcase_35 AC 250 ms
6,104 KB
testcase_36 AC 57 ms
6,104 KB
testcase_37 WA -
testcase_38 TLE -
testcase_39 AC 2,312 ms
5,596 KB
testcase_40 AC 2,365 ms
5,656 KB
testcase_41 AC 2,383 ms
5,896 KB
testcase_42 AC 2,335 ms
5,636 KB
testcase_43 AC 2,323 ms
5,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int c[200][100][100];
vector<set<int>> nums[200];

int main(void) {
    int i, j, k, n, m;
    scanf("%d%d",&n,&m);
    REP (k,m) REP (i,n) REP (j,n) scanf("%d",&c[k][i][j]);

    REP (k,m) {
        REP (i,n) {
            set<int> st;
            REP (j,n) st.insert(c[k][i][j]);
            nums[k].push_back(st);
        }
        REP (j,n) {
            set<int> st;
            REP (i,n) st.insert(c[k][i][j]);
            nums[k].push_back(st);
        }
        {
            set<int> st;
            REP (i,n) st.insert(c[k][i][i]);
            nums[k].push_back(st);
        }
        {
            set<int> st;
            REP (i,n) st.insert(c[k][i][n-i-1]);
            nums[k].push_back(st);
        }
    }

    int a, b, ans = 1e8;
    REP (a,m) REP (b,m) if (a != b) {
        REP (i,n) {
            set<int> st;
            REP (j,n) st.insert(c[b][i][j]);
            for (auto s: nums[a]) {
                int same = 0;
                for (auto x: s) same += st.count(x);
                ans = min(ans,2*n-same-1);
            }
        }
        REP (j,n) {
            set<int> st;
            REP (i,n) st.insert(c[b][i][j]);
            for (auto s: nums[a]) {
                int same = 0;
                for (auto x: s) same += st.count(x);
                ans = min(ans,2*n-same-1);
            }
        }
        {
            set<int> st;
            REP (i,n) st.insert(c[b][i][i]);
            for (auto s: nums[a]) {
                int same = 0;
                for (auto x: s) same += st.count(x);
                ans = min(ans,2*n-same-1);
            }
        }
        {
            set<int> st;
            REP (i,n) st.insert(c[b][i][n-i-1]);
            for (auto s: nums[a]) {
                int same = 0;
                for (auto x: s) same += st.count(x);
                ans = min(ans,2*n-same-1);
            }
        }
    }
    ans = max(ans,n);
    printf("%d\n",ans);
    return 0;
}
0