結果

問題 No.1345 Beautiful BINGO
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-01-12 16:53:24
言語 C++17(clang)
(14.0.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,799 bytes
コンパイル時間 4,133 ms
コンパイル使用メモリ 132,524 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-20 02:56:16
合計ジャッジ時間 11,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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;
  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];
    }
  }
  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