結果
| 問題 | 
                            No.90 品物の並び替え
                             | 
                    
| コンテスト | |
| ユーザー | 
                             alpha_virginis
                         | 
                    
| 提出日時 | 2015-09-14 01:31:50 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,674 bytes | 
| コンパイル時間 | 1,255 ms | 
| コンパイル使用メモリ | 158,988 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-19 06:24:43 | 
| 合計ジャッジ時間 | 1,627 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 6 WA * 3 | 
ソースコード
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>
typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;
const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);
typedef std::pair<int, int> P;
template<typename T>
void print_array(T *A_, s32 size) {
  printf("%d\n", size);
  if( size != 0 ) {
    for(int i = 0; i < size - 1; ++i) {
      printf("%d ", A_[i]);
    }
    printf("%d\n", A_[size - 1]);
  }
}
template<typename T>
inline std::istream& operator >> (std::istream& is, std::complex<T>& C) {
  T R, I;
  std::cin >> R >> I;
  C = std::complex<T>(R, I);
  return is;
}
int A[10];
int n, m;
int score[16][16];
int calc(void) {
  int res = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = i + 1; j < n; ++j) {
      res += score[A[i]][A[j]];
    }
  }
  return res;
}
void rand_swap(void) {
  std::swap(A[rand() % n], A[rand() % n]);
}
int main() {
  std::cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    int a, b, s;
    std::cin >> a >> b >> s;
    score[a][b] = s;
  }
  for(int i = 0; i < n; ++i) {
    A[i] = i;
  }
  
  int res = -1;
  int times = 300;
  int temp;
  srand(time(NULL));
  for(int i = 0; i < times; ++i) {
    int res2 = -1;
    for(int j = 0; j < 8; ++j) {
      rand_swap();
    }
    for(int p = 0; p < n; ++p) {
      for(int q = p + 1; q < n; ++q) {
        std::swap(A[p], A[q]);
        temp = calc();
        std::swap(A[p], A[q]);
        if( res2 < temp ) {
          res2 = temp;
        }
      }
    }
    res = std::max(res, res2);
  }
  std::cout << res << std::endl;
  
  return 0;
}
            
            
            
        
            
alpha_virginis