結果

問題 No.3011 品物の並び替え (Extra)
ユーザー cielciel
提出日時 2015-05-04 00:19:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 574 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 76,404 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-19 06:12:53
合計ジャッジ時間 19,042 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1,725 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1,541 ms
4,380 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <cstdio>
using namespace std;

int main(){
	int N,M;
	scanf("%d%d",&N,&M);
	unordered_map<int,unordered_map<int,int> >m;
	for(;M--;){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		m[a][b]=c;
	}
	vector<int>v(N),order;
	iota(v.begin(),v.end(),0);
	int r=0;
	for(int i=0;i<100000;i++){
		random_shuffle(v.begin(),v.end());
		int s=0;
		for(int i=0;i<N-1;i++)for(int j=i+1;j<N;j++)s+=m[v[i]][v[j]];
		if(r<s)r=s,order=v;
	};
	printf("%d",r);
	for(int i=0;i<N;i++)printf(" %d",order[i]);
}
0