結果

問題 No.452 横着者のビンゴゲーム
ユーザー mai
提出日時 2016-12-04 01:10:25
言語 C++14
(gcc 8.3.0)
結果
AC  
実行時間 2,768 ms
コード長 2,996 Byte
コンパイル時間 1,835 ms
使用メモリ 1,708 KB
最終ジャッジ日時 2019-12-04 04:43:45

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
0_sample_1 AC 3 ms
1,536 KB
0_sample_2 AC 2 ms
1,540 KB
0_sample_3 AC 3 ms
1,544 KB
1_small_0 AC 10 ms
1,548 KB
1_small_1 AC 4 ms
1,544 KB
1_small_2 AC 12 ms
1,544 KB
1_small_3 AC 3 ms
1,544 KB
1_small_4 AC 5 ms
1,544 KB
1_small_5 AC 7 ms
1,544 KB
1_small_6 AC 4 ms
1,540 KB
1_small_7 AC 6 ms
1,540 KB
1_small_8 AC 7 ms
1,540 KB
1_small_9 AC 4 ms
1,544 KB
challenge01.txt AC 4 ms
1,536 KB
hand_0 AC 1,579 ms
1,708 KB
hand_1 AC 1,518 ms
1,704 KB
hand_2 AC 880 ms
1,644 KB
hand_3 AC 80 ms
1,568 KB
random_00 AC 251 ms
1,572 KB
random_01 AC 171 ms
1,564 KB
random_02 AC 115 ms
1,556 KB
random_03 AC 609 ms
1,596 KB
random_04 AC 86 ms
1,556 KB
random_05 AC 1,144 ms
1,632 KB
random_06 AC 64 ms
1,556 KB
random_07 AC 41 ms
1,556 KB
random_08 AC 674 ms
1,596 KB
random_09 AC 434 ms
1,572 KB
random_10 AC 284 ms
1,576 KB
random_11 AC 173 ms
1,564 KB
random_12 AC 799 ms
1,600 KB
random_13 AC 126 ms
1,556 KB
random_14 AC 79 ms
1,556 KB
random_15 AC 327 ms
1,568 KB
random_16 AC 287 ms
1,568 KB
random_17 AC 212 ms
1,560 KB
random_18 AC 51 ms
1,556 KB
random_19 AC 50 ms
1,556 KB
random_20 AC 2,768 ms
1,672 KB
random_21 AC 1,799 ms
1,644 KB
random_22 AC 1,802 ms
1,644 KB
random_23 AC 1,800 ms
1,640 KB
random_24 AC 1,793 ms
1,640 KB
random_25 AC 1,799 ms
1,644 KB
テストケース一括ダウンロード

ソースコード

diff #
#include<bits/stdc++.h>

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int width,height;
int m,n;

vector<vector<int>> bingo[200];

int cpa[105],cpb[105];

int main(){
    int i,j,k;
    int x,y,a,b;
    
    cin >> n >> m;
    
    for (i=0;i<m;i++){
        bingo[i].resize(n);
        for (y=0;y<n;y++){
            bingo[i][y].resize(n);
            for (x=0;x<n;x++){
                scanf("%d",&bingo[i][y][x]);
            }
        }
    }
    
    int result = n*2;
    
    set<int> sa,ss;
    for (i=0;i<m-1;i++){
        for (a=0;a<n*2+2;a++){
            sa.clear();
            if (a<n){
                for (k=0;k<n;k++){
                    sa.insert(bingo[i][a][k]);
                }
            }else if (a<2*n){
                for (k=0;k<n;k++){
                    sa.insert(bingo[i][k][a-n]);
                }
            }else if (a==2*n){
                for (k=0;k<n;k++){
                    sa.insert(bingo[i][k][k]);
                }
            }else{
                for (k=0;k<n;k++){
                    sa.insert(bingo[i][k][n-k-1]);
                }
            }
            for (j=i+1;j<m;j++){
                for (b=0;b<n*2+2;b++){
                    ss=sa;
                    if (b<n){
                        for (k=0;k<n;k++){
                            ss.insert(bingo[j][b][k]);
                        }
                    }else if (b<2*n){
                        for (k=0;k<n;k++){
                            ss.insert(bingo[j][k][b-n]);
                        }
                    }else if (b==2*n){
                        for (k=0;k<n;k++){
                            ss.insert(bingo[j][k][k]);
                        }
                    }else{
                        for (k=0;k<n;k++){
                            ss.insert(bingo[j][k][n-k-1]);
                        }
                    }
                    result = min(result,(int)ss.size());
                }
            }
        }
    }
    
    cout << result-1 << endl;
    
    return 0;
}
0