結果
| 問題 | 
                            No.519 アイドルユニット
                             | 
                    
| コンテスト | |
| ユーザー | 
                             goodbaton
                         | 
                    
| 提出日時 | 2017-05-28 23:51:43 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,043 bytes | 
| コンパイル時間 | 621 ms | 
| コンパイル使用メモリ | 82,036 KB | 
| 実行使用メモリ | 65,536 KB | 
| 最終ジャッジ日時 | 2024-10-02 07:34:42 | 
| 合計ジャッジ時間 | 2,259 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 33 WA * 1 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |   scanf("%d",&n);
      |   ~~~~~^~~~~~~~~
main.cpp:38:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |       scanf("%d",f[i]+j);
      |       ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>
typedef long long ll;
using namespace std;
#define debug(x) cerr << #x << " = " << (x) << endl;
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 30
int dp[1<<24];
int main(){
  int n;
  int f[SIZE][SIZE];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      scanf("%d",f[i]+j);
    }
  }
  
  for(int i=0;i<(1<<n)-1;i++){
    
    if((dp[i]==0 && i != 0)) continue;
    
    for(int j=0;j<n;j++){
      if((1<<j) & i) continue;
      for(int k=j+1;k<n;k++){
        if((1<<k) & i) continue;
        
        dp[i | (1<<j) | (1<<k)] = max(dp[i | (1<<j) | (1<<k)], dp[i] + f[j][k]);
        
      }
      break;
    }
    
  }
  
  printf("%d\n",dp[(1<<n)-1]);
  
  return 0;
}
            
            
            
        
            
goodbaton