結果
| 問題 | 
                            No.8011 品物の並び替え (Extra)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-05-04 00:19:49 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 574 bytes | 
| コンパイル時間 | 690 ms | 
| コンパイル使用メモリ | 64,988 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-05 18:27:50 | 
| 合計ジャッジ時間 | 19,217 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 WA * 7 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d%d",&N,&M);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d%d%d",&a,&b,&c);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~
            
            ソースコード
#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]);
}