結果
| 問題 |
No.8011 品物の並び替え (Extra)
|
| コンテスト | |
| ユーザー |
Kmcode1
|
| 提出日時 | 2015-05-03 23:48:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,436 bytes |
| コンパイル時間 | 940 ms |
| コンパイル使用メモリ | 99,028 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 17:55:55 |
| 合計ジャッジ時間 | 46,705 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:52:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
52 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:55:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
55 | scanf("%d%d%d", &a, &b, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
using namespace std;
int n;
int m;
#define MAX 51
vector<pair<int, pair<int,int> > > v;
vector<int> ans;
int maxt = 0;
vector<int> ord;
int flag[MAX];
void score(){
for (int i = 0; i < ord.size(); i++){
flag[ord[i]] = i;
}
int kari = 0;
for (int i = 0; i < v.size(); i++){
if (flag[v[i].first] < flag[v[i].second.first]){
kari += v[i].second.second;
}
}
if (maxt < kari){
maxt = kari;
ans = ord;
}
}
int main(){
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
v.push_back(make_pair(a, make_pair(b, c)));
}
for (int i = 0; i < n; i++){
ord.push_back(i);
}
maxt = -1;
score();
reverse(ord.begin(), ord.end());
score();
reverse(ord.begin(), ord.end());
double st = clock();
while ((clock()-st) / (double)(CLOCKS_PER_SEC) < 4.5){
random_shuffle(ord.begin(), ord.end());
score();
}
printf("%d\n", maxt);
for (int i = 0; i < ans.size(); i++){
if (i){
cout << " ";
}
cout << ans[i];
}
puts("");
return 0;
}
Kmcode1