結果
問題 | No.3011 品物の並び替え (Extra) |
ユーザー | tails |
提出日時 | 2015-05-04 00:08:58 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1,015 ms / 5,000 ms |
コード長 | 814 bytes |
コンパイル時間 | 1,444 ms |
コンパイル使用メモリ | 144,520 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-19 05:47:04 |
合計ジャッジ時間 | 8,557 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 425 ms
4,380 KB |
testcase_01 | AC | 629 ms
4,384 KB |
testcase_02 | AC | 976 ms
4,380 KB |
testcase_03 | AC | 897 ms
4,384 KB |
testcase_04 | AC | 658 ms
4,380 KB |
testcase_05 | AC | 431 ms
4,380 KB |
testcase_06 | AC | 459 ms
4,376 KB |
testcase_07 | AC | 597 ms
4,380 KB |
testcase_08 | AC | 1,015 ms
4,384 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; int n,m; int t[50][50]; int a[50],b[50]; int main(){ cin>>n>>m; for(int j=0;j<m;++j){ int a,b,s; cin >>a>>b>>s; t[a][b]=s; } srand(1); for(int i=0;i<n;++i){ a[i]=i; } int e=0; for(int c=0;c<1000000;++c){ for(int i=0;i<n;++i){ b[i]=a[i]; } { int i=rand()%n; int j=rand()%n; if(i!=j)b[i]^=b[j]^=b[i]^=b[j]; } { int i=rand()%n; int j=rand()%n; if(i!=j)b[i]^=b[j]^=b[i]^=b[j]; } int r=0; for(int i=0;i<n;++i){ for(int j=i+1;j<n;++j){ r+=t[b[i]][b[j]]; } } if(r>e){ e=r; for(int i=0;i<n;++i){ a[i]=b[i]; } } } cout << e << endl; for(int i=0;i<n;++i){ cout << a[i] << " "; } cout << endl; return 0; }