結果

問題 No.1345 Beautiful BINGO
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-01-12 16:54:27
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,879 bytes
コンパイル時間 2,463 ms
コンパイル使用メモリ 164,924 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 07:27:41
合計ジャッジ時間 7,703 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 74 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 75 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 1 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
//const ll mod = 998244353;
const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll n,m;
  cin>>n>>m;
  assert(2<=n&&n<=8&&1<=m&&m<=2*(n+1));
  vector<vector<ll>> a(n,vector<ll>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
      assert(1<=a[i][j]&&a[i][j]<=100);
    }
  }
  ll ans=inf;
  for(int i=0;i<(1<<(2*n+2));i++){
    ll f=i;
    ll tmp=0;
    while(f>0){
      tmp+=f%2;
      f/=2;
    }
    if(tmp<m){
      continue;
    }
    vector<vector<ll>> t(n,vector<ll>(n));
    f=i;
    for(int j=0;j<n;j++){
      if(f%2){
        for(int k=0;k<n;k++){
          t[j][k]=1;
        }
      }
      f/=2;
    }
    for(int j=0;j<n;j++){
      if(f%2){
        for(int k=0;k<n;k++){
          t[k][j]=1;
        }
      }
      f/=2;
    }
    if(f%2){
      for(int j=0;j<n;j++){
        t[j][j]=1;
      }
    }
    f/=2;
    if(f%2){
      for(int j=0;j<n;j++){
        t[j][(n-1-j)]=1;
      }
    }
    ll z=0;
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        z+=t[j][k]*a[j][k];
      }
    }
    chmin(ans,z);
  }
  cout<<ans<<endl;
}
0