結果

問題 No.1473 おでぶなおばけさん
ユーザー nuxxppnuxxpp
提出日時 2021-04-10 21:51:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,024 bytes
コンパイル時間 3,788 ms
コンパイル使用メモリ 164,304 KB
実行使用メモリ 9,996 KB
最終ジャッジ日時 2023-09-08 17:32:01
合計ジャッジ時間 7,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,780 KB
testcase_01 AC 3 ms
5,780 KB
testcase_02 WA -
testcase_03 AC 47 ms
9,252 KB
testcase_04 AC 28 ms
7,700 KB
testcase_05 AC 13 ms
6,904 KB
testcase_06 AC 52 ms
9,760 KB
testcase_07 AC 59 ms
9,520 KB
testcase_08 AC 56 ms
9,612 KB
testcase_09 AC 57 ms
9,452 KB
testcase_10 WA -
testcase_11 AC 31 ms
8,700 KB
testcase_12 AC 32 ms
8,264 KB
testcase_13 AC 20 ms
7,068 KB
testcase_14 AC 16 ms
6,868 KB
testcase_15 AC 27 ms
7,804 KB
testcase_16 AC 30 ms
7,644 KB
testcase_17 AC 6 ms
6,092 KB
testcase_18 AC 6 ms
6,392 KB
testcase_19 AC 31 ms
8,204 KB
testcase_20 AC 39 ms
8,976 KB
testcase_21 AC 48 ms
9,000 KB
testcase_22 AC 51 ms
9,400 KB
testcase_23 AC 40 ms
8,744 KB
testcase_24 AC 40 ms
8,852 KB
testcase_25 AC 56 ms
9,620 KB
testcase_26 AC 50 ms
9,496 KB
testcase_27 AC 21 ms
7,340 KB
testcase_28 AC 53 ms
9,372 KB
testcase_29 AC 43 ms
8,692 KB
testcase_30 AC 53 ms
9,420 KB
testcase_31 WA -
testcase_32 AC 52 ms
9,972 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 40 ms
8,516 KB
testcase_37 AC 39 ms
8,564 KB
testcase_38 AC 10 ms
6,376 KB
testcase_39 WA -
testcase_40 AC 30 ms
7,832 KB
testcase_41 AC 26 ms
7,220 KB
testcase_42 AC 27 ms
7,352 KB
testcase_43 AC 39 ms
9,024 KB
testcase_44 AC 40 ms
9,176 KB
testcase_45 AC 40 ms
9,052 KB
testcase_46 AC 40 ms
8,544 KB
testcase_47 AC 46 ms
8,960 KB
testcase_48 AC 45 ms
8,500 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘P dijkstra(int, int)’ 内:
main.cpp:60:12: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   60 |       auto [v, w] = g[e.now][i];
      |            ^
main.cpp: 関数 ‘int main()’ 内:
main.cpp:84:8: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   84 |   auto [we, co] = dijkstra(n - 1, 0);
      |        ^
main.cpp: 関数 ‘P dijkstra(int, int)’ 内:
main.cpp:68:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   68 | }
      | ^

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>
#include <stack>
#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < (t); ++i)
#define dsrep(i,t,s) for(int i = (t)-1; i >= (s); --i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 998244353;

////////////////////////////////////////////
int n, m;
vector<P> g[100005];
struct edge
{
  int now, front, we, co;
  bool operator< (edge edge2) const {
    if(this->we == edge2.we) {
      return this->co > edge2.co;
    } else {
      return this->we < edge2.we;
    }
  }
};

P dijkstra(int s, int goal) {
  priority_queue<edge> que;
  vector<int> d(n, -1);
  que.push(edge{s, -1, INF, 0});

  while (!que.empty()) {
    edge e = que.top(); que.pop();
    if(d[e.now] > e.we) continue;
    if(e.now == goal) return {e.we, e.co};
    for(int i = 0; i < g[e.now].size(); i++) {
      auto [v, w] = g[e.now][i];
      // cout << d[e.now] << " " << e.now << " " << e.front << " " << e.we << " " << e.co << endl;
      if(d[v] < min(e.we, w)) {
        d[v] = min(e.we, w);
        que.push(edge{v, e.now, d[v], e.co + 1});
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;

  int a, b, c;
  rep(i, m) {
    cin >> a >> b >> c;
    a--; b--;
    g[a].push_back(P(b, c));
    g[b].push_back(P(a, c));
  }

  auto [we, co] = dijkstra(n - 1, 0);
  cout << we << " " << co << endl;
}
0