結果
問題 | No.452 横着者のビンゴゲーム |
ユーザー |
|
提出日時 | 2020-03-04 14:27:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 327 ms / 3,000 ms |
コード長 | 1,067 bytes |
コンパイル時間 | 554 ms |
コンパイル使用メモリ | 68,524 KB |
実行使用メモリ | 9,816 KB |
最終ジャッジ日時 | 2024-10-14 00:14:20 |
合計ジャッジ時間 | 3,771 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
コンパイルメッセージ
main.cpp:39:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 39 | main() | ^~~~
ソースコード
#include<iostream>using namespace std;int N,M;int A[200][100][100];int ex[40404];int tm;bool ise(int a){if(ex[a]<tm){ex[a]=tm;return true;}else return false;}bool f(int K){tm=0;for(int i=0;i<40404;i++)ex[i]=0;for(int i=0;i<M;i++)for(int j=i+1;j<M;j++){for(int I=0;I<2*N+2;I++)for(int J=0;J<2*N+2;J++){tm++;int cnt=0;if(I<N)for(int k=0;k<N;k++)cnt+=ise(A[i][I][k]);else if(I<2*N)for(int k=0;k<N;k++)cnt+=ise(A[i][k][I-N]);else if(I==2*N)for(int k=0;k<N;k++)cnt+=ise(A[i][k][k]);else for(int k=0;k<N;k++)cnt+=ise(A[i][N-k-1][k]);if(J<N)for(int k=0;k<N;k++)cnt+=ise(A[j][J][k]);else if(J<2*N)for(int k=0;k<N;k++)cnt+=ise(A[j][k][J-N]);else if(J==2*N)for(int k=0;k<N;k++)cnt+=ise(A[j][k][k]);else for(int k=0;k<N;k++)cnt+=ise(A[j][N-k-1][k]);if(cnt<=K)return true;}}return false;}main(){cin>>N>>M;for(int i=0;i<M;i++)for(int j=0;j<N;j++)for(int k=0;k<N;k++)cin>>A[i][j][k];int L=N-1,R=2*N;while(R-L>1){if(f((L+R)/2))R=(L+R)/2;else L=(L+R)/2;}cout<<L<<endl;}