結果
問題 |
No.519 アイドルユニット
|
ユーザー |
![]() |
提出日時 | 2025-03-18 22:02:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,051 bytes |
コンパイル時間 | 2,198 ms |
コンパイル使用メモリ | 192,236 KB |
実行使用メモリ | 101,872 KB |
最終ジャッジ日時 | 2025-03-18 22:03:06 |
合計ジャッジ時間 | 10,636 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 29 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define fi first #define sc second #define pii pair<int,int> #define pdd pair<double,double> #define pb push_back #define umap unordered_map #define mset multiset #define pq priority_queue #define ull unsigned long long #define i128 __int128 #define ld long double #define fixs fixed<<setprecision const int maxn=24+10,maxs=(1<<24)+10; int n,a[maxn][maxn],f[maxs]; short p[maxs]; void solve(){ cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++) cin>>a[i][j]; } for(int i=1;i<(1<<n);i++){ p[i]=p[i>>1]+(i&1); if(p[i]&1) continue; int id=__lg(i&(-i))+1; for(int j=1;j<=n;j++){ if(!(i&(1<<(j-1)))) continue; f[i]=max(f[i],a[id][j]+f[i-(1<<(id-1))-(1<<(j-1))]); } } cout<<f[(1<<n)-1]<<endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); int t=1; // cin>>t; while(t--) solve(); return 0; } /* Samples input: output: THINGS TODO: ??freopen??????? ???? ???????????? */