結果

問題 No.452 横着者のビンゴゲーム
ユーザー imulanimulan
提出日時 2016-12-03 01:14:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 288 ms / 3,000 ms
コード長 1,625 bytes
コンパイル時間 1,769 ms
コンパイル使用メモリ 175,992 KB
実行使用メモリ 10,000 KB
最終ジャッジ日時 2023-08-19 06:59:21
合計ジャッジ時間 5,787 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,388 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 106 ms
4,376 KB
testcase_15 AC 103 ms
4,380 KB
testcase_16 AC 58 ms
4,380 KB
testcase_17 AC 7 ms
8,112 KB
testcase_18 AC 31 ms
4,376 KB
testcase_19 AC 23 ms
4,380 KB
testcase_20 AC 17 ms
5,876 KB
testcase_21 AC 70 ms
4,508 KB
testcase_22 AC 14 ms
7,788 KB
testcase_23 AC 124 ms
4,384 KB
testcase_24 AC 9 ms
9,896 KB
testcase_25 AC 7 ms
5,780 KB
testcase_26 AC 78 ms
4,380 KB
testcase_27 AC 58 ms
4,384 KB
testcase_28 AC 34 ms
4,376 KB
testcase_29 AC 24 ms
4,384 KB
testcase_30 AC 90 ms
4,380 KB
testcase_31 AC 16 ms
4,376 KB
testcase_32 AC 12 ms
5,960 KB
testcase_33 AC 43 ms
6,064 KB
testcase_34 AC 37 ms
4,380 KB
testcase_35 AC 29 ms
6,176 KB
testcase_36 AC 8 ms
5,764 KB
testcase_37 AC 8 ms
10,000 KB
testcase_38 AC 288 ms
4,380 KB
testcase_39 AC 199 ms
4,380 KB
testcase_40 AC 198 ms
4,380 KB
testcase_41 AC 197 ms
4,380 KB
testcase_42 AC 199 ms
4,376 KB
testcase_43 AC 198 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,m;
    int c[200][100][100];

    scanf(" %d %d", &n, &m);
    rep(i,m)rep(j,n)rep(k,n) scanf(" %d", &c[i][j][k]);

    vector<vector<int>> bingo[200];
    rep(i,m)
    {
        vector<int> tmp(n);

        // 縦
        rep(j,n)
        {
            rep(k,n) tmp[k]=c[i][k][j];
            sort(all(tmp));
            bingo[i].pb(tmp);
        }
        // 横
        rep(j,n)
        {
            rep(k,n) tmp[k]=c[i][j][k];
            sort(all(tmp));
            bingo[i].pb(tmp);
        }
        //斜め
        rep(j,n) tmp[j]=c[i][j][j];
        sort(all(tmp));
        bingo[i].pb(tmp);
        rep(j,n) tmp[j]=c[i][n-1-j][j];
        sort(all(tmp));
        bingo[i].pb(tmp);
    }

    int ans=123456;
    rep(i,m)rep(j,i)
    {
        rep(a,bingo[i].size())rep(b,bingo[j].size())
        {
            int S=0;
            int x=0,y=0;

            while(x<n && y<n)
            {
                if(bingo[i][a][x] < bingo[j][b][y]) ++x;
                else if(bingo[i][a][x] > bingo[j][b][y]) ++y;
                else
                {
                    ++x;
                    ++y;
                }
                ++S;
            }
            S+=n-x+n-y;
            
            ans=min(ans,S-1);
        }
    }

    if(ans<1) ans=1;
    printf("%d\n", ans);
    return 0;
}
0