結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー yuppe19 😺yuppe19 😺
提出日時 2016-12-18 11:53:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,572 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 78,344 KB
実行使用メモリ 24,988 KB
最終ジャッジ日時 2024-05-08 06:28:10
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |   int n, m; scanf("%d%d", &n, &m);
      |             ~~~~~^~~~~~~~~~~~~~~~
main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |     scanf("%d%d%d", &a, &b, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
using namespace std;

struct edge {
  int to, cost;
};

int main(void) {
  int n, m; scanf("%d%d", &n, &m);
  vector<vector<edge>> G0(n, vector<edge>()); // G[n][]
  vector<vector<edge>> rG(n, vector<edge>()); // revG[n][]
  int a, b, c;
  for(int i=0; i<m; ++i) {
    scanf("%d%d%d", &a, &b, &c);
    G0[a].push_back(edge({b, c}));
    rG[b].push_back(edge({a, c}));
  }
  vector<int> cost0(n, -1); // cost[n]
  cost0[0] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>> que0;
  // コスト、点番号
  que0.emplace(0, 0);
  while(!que0.empty()) {
    int cc, v; tie(cc, v) = que0.top(); que0.pop();
    if(cc < cost0[v]) { continue; }
    for(edge& e : G0[v]) {
      if(cost0[e.to] < cost0[v] + e.cost) {
        cost0[e.to] = cost0[v] + e.cost;
        que0.emplace(cost0[e.to], e.to);
      }
    }
  }

  puts("a");

//  vector<int> rcost(n, -1); // rcost[n]
//  rcost[n-1] = 0;
//  priority_queue<pair<int, int>, vector<pair<int, int>>> rq;
//  // コスト、点番号
//  rq.emplace(0, n-1);
//  while(!rq.empty()) {
//    int cc, v; tie(cc, v) = rq.top(); rq.pop();
//    if(cc < rcost[v]) { continue; }
//    for(edge& e : rG[v]) {
//      if(rcost[e.to] < rcost[v] + e.cost) {
//        rcost[e.to] = rcost[v] + e.cost;
//        rq.emplace(rcost[e.to], e.to);
//      }
//    }
//  }
//
//  int days = cost0[n-1];
//  int cnt = 0;
//  for(int i=0; i<n; ++i) {
//    if(cost0[i] != days - rcost[i]) { ++cnt; }
//  }
//  printf("%d %d/%d\n", days, cnt, n);
  return 0;
}
0