結果
問題 | No.452 横着者のビンゴゲーム |
ユーザー |
![]() |
提出日時 | 2016-12-05 09:48:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 377 ms / 3,000 ms |
コード長 | 1,808 bytes |
コンパイル時間 | 1,190 ms |
コンパイル使用メモリ | 88,756 KB |
実行使用メモリ | 16,092 KB |
最終ジャッジ日時 | 2024-11-29 00:09:51 |
合計ジャッジ時間 | 4,709 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
/* -*- coding: utf-8 -*- * * 452.cc: No.452 横着者のビンゴゲーム - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_N = 100; const int MAX_K = MAX_N * 2 + 2; const int MAX_M = 200; const int INF = 1 << 30; /* typedef */ typedef vector<int> vi; typedef queue<int> qi; typedef pair<int,int> pii; /* global variables */ int cs[MAX_N][MAX_N]; int bs[MAX_M][MAX_K][MAX_N]; /* subroutines */ /* main */ int main() { int n, m; cin >> n >> m; int l = n * 2 + 2; for (int i = 0; i < m; i++) { for (int y = 0; y < n; y++) for (int x = 0; x < n; x++) cin >> cs[y][x]; int j = 0; for (int y = 0; y < n; y++, j++) for (int x = 0; x < n; x++) bs[i][j][x] = cs[y][x]; for (int x = 0; x < n; x++, j++) for (int y = 0; y < n; y++) bs[i][j][y] = cs[y][x]; for (int y = 0; y < n; y++) bs[i][j][y] = cs[y][y]; j++; for (int y = 0; y < n; y++) bs[i][j][y] = cs[y][n - 1 - y]; for (int j = 0; j < l; j++) sort(bs[i][j], bs[i][j] + n); } int maxc = 0; for (int i0 = 0; i0 < m; i0++) for (int i1 = i0 + 1; i1 < m; i1++) for (int j0 = 0; j0 < l; j0++) for (int j1 = 0; j1 < l; j1++) { int c = 0; for (int k0 = 0; k0 < n; k0++) { int k1 = lower_bound(bs[i1][j1], bs[i1][j1] + n, bs[i0][j0][k0]) - bs[i1][j1]; if (k1 < n && bs[i1][j1][k1] == bs[i0][j0][k0]) c++; } if (maxc < c) maxc = c; } //printf("maxc=%d\n", maxc); printf("%d\n", n * 2 - maxc - 1); return 0; }