結果
| 問題 |
No.8011 品物の並び替え (Extra)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-04 01:00:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,321 bytes |
| コンパイル時間 | 1,498 ms |
| コンパイル使用メモリ | 165,156 KB |
| 実行使用メモリ | 8,576 KB |
| 最終ジャッジ日時 | 2024-07-05 18:40:08 |
| 合計ジャッジ時間 | 13,816 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int(i)=0;(i)<(n);++(i))
#define FOR(i, f, t) for(int(i)=(f);(i)<(t);(++i))
const int MOD = int(1e9+9);
int N,M;
int k[55],kk[55];
map<int,int> m[55];
unsigned int xor128(void) {
static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
unsigned int t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}
int score(){
ll mask = 0;
int sc = 0;
REP(i,N){
auto &a = m[k[i]];
for(auto it = a.begin(); it != a.end(); ++it){
int b = it->first, c = it->second;
if((mask >> b)&1) continue;
sc += c;
}
mask |= 1LL<<k[i];
}
return sc;
}
int main(){
cin >> N >> M;
REP(i,M){
int a,b,c;
cin >> a >> b >> c;
m[a].insert(make_pair(b,c));
}
REP(i,N) k[i] = kk[i] = i;
int sc = score();
clock_t t = clock() + CLOCKS_PER_SEC * 10;
while(t >= clock()){
int i = xor128() % N;
int j = xor128() % N;
if(i == j) continue;
swap(k[i],k[j]);
int s = score();
if(sc < s){
sc = s;
REP(i,N) kk[i] = k[i];
}
}
cout << sc << endl;
REP(i,N) cout << kk[i] << " ";
return 0;
}