結果

問題 No.519 アイドルユニット
ユーザー 小指が強い人小指が強い人
提出日時 2017-08-27 12:53:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 741 ms / 1,000 ms
コード長 3,215 bytes
コンパイル時間 2,546 ms
コンパイル使用メモリ 183,992 KB
実行使用メモリ 68,992 KB
最終ジャッジ日時 2023-08-06 03:41:59
合計ジャッジ時間 9,467 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 736 ms
68,824 KB
testcase_01 AC 741 ms
68,992 KB
testcase_02 AC 179 ms
19,672 KB
testcase_03 AC 12 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 12 ms
4,436 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 12 ms
4,440 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 12 ms
4,380 KB
testcase_17 AC 12 ms
4,396 KB
testcase_18 AC 12 ms
4,376 KB
testcase_19 AC 12 ms
4,380 KB
testcase_20 AC 12 ms
4,380 KB
testcase_21 AC 12 ms
4,476 KB
testcase_22 AC 12 ms
4,400 KB
testcase_23 AC 12 ms
4,384 KB
testcase_24 AC 44 ms
7,460 KB
testcase_25 AC 44 ms
7,632 KB
testcase_26 AC 45 ms
7,684 KB
testcase_27 AC 44 ms
7,424 KB
testcase_28 AC 44 ms
7,432 KB
testcase_29 AC 736 ms
68,912 KB
testcase_30 AC 738 ms
68,896 KB
testcase_31 AC 736 ms
68,948 KB
testcase_32 AC 734 ms
68,928 KB
testcase_33 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T, class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<char c = ' ',class T> void write(T a){cout << fixed << setprecision(15) << a << endl;}
template<char c = ' ',class T,class ...Args> void write(T a, Args... args){cout << fixed << setprecision(4) << a << c; write<c>(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ull gcd(ull a, ull b){while(true){ull k = a % b;if(k == 0)return b;a = b;b = k;}}
ull lcm(ull a, ull b){return a*b/gcd(a,b);}
ull comb(ull n, ull m){ull p=1;m=min(m,n-m);for(ull i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

inline int numofbits5(long bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

inline bool bFlag(int bit,int n){
    return (bit&(1<<n))>0;
}

int dp[1<<24]={0};

int main(void)
{
    clock_t start = clock();    // スタート時間
    
    //vector<int> dp;
    int n,mt[30][30];
    read(n);
    rep(i,n)rep(j,n)read(mt[i][j]);
    int pn=1<<n;
    //dp.resize(pn);
    int x,i,j;
    for(x=0;x<pn-1;x++){
        if(__builtin_popcount(x)&1)continue;
        for(i=0;i<n-1;i++){
            if(x&(1<<i))continue;
            for(j=i+1;j<n;j++){
                if(x&(1<<j))continue;
                int nx=x|(1<<i)|(1<<j);
                dp[nx]=max(dp[nx],dp[x]+mt[i][j]);
            }
            break;
        }
    }
    write(dp[pn-1]);
    //std::cout << "duration = " << (double)(clock() - start) / CLOCKS_PER_SEC << "sec.\n";
    return 0;
}
0