結果
| 問題 |
No.519 アイドルユニット
|
| コンテスト | |
| ユーザー |
furon
|
| 提出日時 | 2023-10-26 23:23:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,620 bytes |
| コンパイル時間 | 1,301 ms |
| コンパイル使用メモリ | 126,392 KB |
| 最終ジャッジ日時 | 2025-02-17 13:52:50 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 TLE * 6 |
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <random>
using namespace std;
using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using vs = vector<string>;
using pii = pair<int, int>; using vpii = vector<pii>;
using pil = pair<int, ll>; using vpil = vector<pil>;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using pdd = pair<double, double>; using vpdd = vector<pdd>;
const int inf = (1 << 30) - 1;
const ll INF = 1LL << 60;
//const int MOD = 1000000007;
const int MOD = 998244353;
template<typename T> inline bool chmax(T& a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T& a, T b) { return ((a > b) ? (a = b, true) : (false)); }
int main() {
int n;
cin >> n;
vvi f(n, vi(n, 0));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int x;
cin >> x;
f[i][j] = f[j][i] = x;
}
}
vl dp(1 << n, 0);
for (int b = 0; b < (1 << n) - 1; b++) {
int x = -1;
for (int i = 0; i < n; i++) {
if ((b & (1 << i)) == 0) {
x = i;
break;
}
}
for (int i = 0; i < n; i++) {
if ((b & (1 << i)) == 0) {
int to = b | (1 << x) | (1 << i);
chmax(dp[to], dp[b] + f[x][i]);
}
}
}
cout << dp[(1 << n) - 1] << endl;
return 0;
}
furon