結果
| 問題 | No.519 アイドルユニット |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-03-14 15:05:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 1,000 ms |
| コード長 | 1,219 bytes |
| 記録 | |
| コンパイル時間 | 2,269 ms |
| コンパイル使用メモリ | 202,004 KB |
| 実行使用メモリ | 8,576 KB |
| 最終ジャッジ日時 | 2025-03-14 15:05:46 |
| 合計ジャッジ時間 | 4,720 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘void AC::solve()’:
main.cpp:13:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
13 | scanf("%d",&n);
| ~^ ~~
| | |
| | long long int*
| int*
| %lld
main.cpp:16:33: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
16 | scanf("%d",&e);
| ~^ ~~
| | |
| | long long int*
| int*
| %lld
main.cpp:48:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::map<long long int, long long int>::mapped_type’ {aka ‘long long int’} [-Wformat=]
48 | printf("%d\n",dp[n][(1<<n)-1]);
| ~^
| |
| int
| %lld
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:16:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d",&e);
| ~~~~~^~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
template<typename T>istream&operator>>(istream&I,vector<T>&v){for(auto&i:v)I>>i;return I;}
template<typename T>ostream&operator<<(ostream&O,vector<T>&v){for(auto&i:v)O<<i<<' ';return O;}
namespace AC{
int n,e;
int as[31][31];
void solve(){
std::map<int,int> dp[31];
scanf("%d",&n);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
scanf("%d",&e);
as[i][j]=e;
}
}
dp[0][0]=0;
for(int i=0;i<n;i+=2){
std::map<int,int>::iterator it;
for(it=dp[i].begin();it!=dp[i].end();it++){
int perm=(*it).first;
int score=(*it).second;
for(int k=0;k<n;k++){
int add1=(1<<k);
if((perm&add1)!=0){
continue;
}
for(int l=k+1;l<n;l++){
if(k==l)continue;
int add2=(add1|(1<<l));
if((perm&add2)!=0)continue;
int perm2=(perm|add2);
int score2=score+as[k][l];
if(dp[i+2].find(perm2)==dp[i+2].end()){
dp[i+2][perm2]=score2;
}else if(dp[i+2][perm2]<score2){
dp[i+2][perm2]=score2;
}
}
break;
}
}
}
printf("%d\n",dp[n][(1<<n)-1]);
}
}
signed main(){
int t=1;
//cin>>t;
while(t--)AC::solve();
}
vjudge1