結果

問題 No.519 アイドルユニット
コンテスト
ユーザー TangentDay
提出日時 2017-05-28 21:47:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 1,043 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 81,944 KB
実行使用メモリ 68,864 KB
最終ジャッジ日時 2024-09-21 15:22:33
合計ジャッジ時間 14,587 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28 TLE * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:13: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |         int y;
      |             ^

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n;
    int f[24][24];
    cin >> n;
    REP(i,n) REP(j,n) cin >> f[i][j];

    VI dp(1<<n);
    REP(x,1<<n){
        int y;
        REP(i,n){
            if (((x>>i) & 1) == 0){
                y = i;
                break;
            }
        }
        FOR(z,y+1,n-1){
            if ((x >> z) & 1) continue;
            dp[x | (1<<y) | (1<<z)] = max(dp[x | (1<<y) | (1<<z)], dp[x] + f[y][z]);
        }
    }
    cout << dp[(1<<n)-1] << endl;
    return 0;
}
0