結果
問題 | No.452 横着者のビンゴゲーム |
ユーザー |
|
提出日時 | 2019-10-17 17:29:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,274 bytes |
コンパイル時間 | 845 ms |
コンパイル使用メモリ | 79,212 KB |
実行使用メモリ | 7,296 KB |
最終ジャッジ日時 | 2024-06-24 20:16:46 |
合計ジャッジ時間 | 7,256 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 7 RE * 2 |
ソースコード
#include<iostream>#include<set>#include<vector>using namespace std;int main(){cin.tie(0);ios::sync_with_stdio(false);int n, m;cin >> n >> m;int c[m][n][n];for(int i = 0; i < m; i++){for(int j = 0; j < n*n; j++){cin >> c[i][j/n][j%n];}}set<int> s[m][2*n+2];for(int i = 0; i < m; i++){for(int j = 0; j < n; j++){s[i][2*n].insert(c[i][j][j]);s[i][2*n+1].insert(c[i][n-1-j][j]);}for(int j = 0; j < n; j++){for(int k = 0; k < n; k++){s[i][j].insert(c[i][j][k]);s[i][n+j].insert(c[i][k][j]);}}}// O(M^2 N^3)int ans = 2*n;vector<bool> v(n*n+m+1,0);for(int i = 0; i < m; i++){for(int j = i+1; j < m; j++){for(int k = 0; k < 2*n+2; k++){for(int l = 0; l < 2*n+2; l++){for(int x : s[i][k]) v[x] = true;int dbl = 0;for(int x : s[j][l]) dbl += v[x];ans = min(ans, (n-dbl)*2+dbl-1);for(int x : s[i][k]) v[x] = false;}}}}cout << ans << endl;return 0;}