結果
問題 |
No.1345 Beautiful BINGO
|
ユーザー |
|
提出日時 | 2021-01-16 20:49:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 544 bytes |
コンパイル時間 | 552 ms |
コンパイル使用メモリ | 67,712 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-11-28 02:56:03 |
合計ジャッジ時間 | 50,807 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 45 TLE * 16 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N,M; int A[16][16]; main() { cin>>N>>M; for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>A[i][j]; long comb=(1L<<M)-1; int ans=1e9; while(comb<1L<<N+N+2) { int now=0; for(int i=0;i<N;i++)for(int j=0;j<N;j++) { if(comb>>i&1||comb>>N+j&1)now+=A[i][j]; else { if(i==j&&comb>>N+N&1)now+=A[i][j]; else if(i+j==N-1&&comb>>N+N+1&1)now+=A[i][j]; } } if(ans>now)ans=now; long x=comb&-comb; long y=comb+x; comb=(comb&~y)/x>>1|y; } cout<<ans<<endl; }