結果

問題 No.519 アイドルユニット
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-05-28 22:53:52
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,688 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 90,676 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 06:34:26
合計ジャッジ時間 14,992 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 406 ms
6,812 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 380 ms
6,944 KB
testcase_05 AC 361 ms
6,944 KB
testcase_06 AC 342 ms
6,944 KB
testcase_07 AC 339 ms
6,940 KB
testcase_08 AC 340 ms
6,944 KB
testcase_09 AC 346 ms
6,944 KB
testcase_10 AC 353 ms
6,944 KB
testcase_11 AC 363 ms
6,940 KB
testcase_12 AC 266 ms
6,940 KB
testcase_13 AC 365 ms
6,940 KB
testcase_14 AC 364 ms
6,940 KB
testcase_15 AC 365 ms
6,944 KB
testcase_16 AC 363 ms
6,940 KB
testcase_17 AC 364 ms
6,940 KB
testcase_18 AC 365 ms
6,940 KB
testcase_19 AC 362 ms
6,940 KB
testcase_20 AC 363 ms
6,940 KB
testcase_21 AC 362 ms
6,944 KB
testcase_22 AC 364 ms
6,940 KB
testcase_23 AC 362 ms
6,944 KB
testcase_24 AC 387 ms
6,944 KB
testcase_25 AC 389 ms
6,940 KB
testcase_26 AC 388 ms
6,944 KB
testcase_27 AC 389 ms
6,940 KB
testcase_28 AC 387 ms
6,948 KB
testcase_29 AC 404 ms
6,940 KB
testcase_30 AC 406 ms
6,944 KB
testcase_31 AC 407 ms
6,940 KB
testcase_32 AC 405 ms
6,944 KB
testcase_33 AC 381 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[50][50];

unsigned int xor128(void) { 
  static unsigned int x = 123456789;
  static unsigned int y = 362436069;
  static unsigned int z = 521288629;
  static unsigned int w = 88675123; 
  unsigned int t;
 
  t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); 
}

int main()
{
  ll n;
  cin>>n;
  rep(i,0,n){
    rep(j,0,n){
      ll a;
      cin>>a;
      d[i][j] = a;
    }
  }
  ll mx = 0;
  rep(i,0,100){
    vector<ll> v;
    rep(j,0,n){
      v.pb(j);
    }
    rep(j,0,1000){
      swap(v[xor128()%n],v[xor128()%n]);
    }
    ll mx1 = 0;
    rep(j,0,100000){
      ll a = xor128()%n;
      ll b = xor128()%n;
      swap(v[a],v[b]);
      ll score = 0;
      rep(k,0,n/2){
        score += d[v[k]][v[k+n/2]];
      }
      if(score>=mx1){
        mx1 = score;
      }
      else{
        swap(v[a],v[b]);
      }
    }
    mx = max(mx,mx1);
  }
  cout << mx << endl;
  return 0;
}
0