結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,856 KB
testcase_01 AC 4 ms
5,748 KB
testcase_02 AC 65 ms
9,684 KB
testcase_03 WA -
testcase_04 AC 35 ms
7,952 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 66 ms
9,424 KB
testcase_08 WA -
testcase_09 AC 68 ms
9,644 KB
testcase_10 AC 31 ms
8,068 KB
testcase_11 WA -
testcase_12 AC 32 ms
8,204 KB
testcase_13 AC 20 ms
6,988 KB
testcase_14 AC 16 ms
6,764 KB
testcase_15 AC 27 ms
7,880 KB
testcase_16 AC 30 ms
7,592 KB
testcase_17 AC 5 ms
5,904 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 51 ms
9,316 KB
testcase_22 AC 50 ms
9,656 KB
testcase_23 AC 42 ms
8,596 KB
testcase_24 AC 42 ms
8,908 KB
testcase_25 AC 54 ms
9,300 KB
testcase_26 AC 53 ms
9,476 KB
testcase_27 AC 21 ms
7,240 KB
testcase_28 AC 63 ms
9,628 KB
testcase_29 AC 46 ms
8,752 KB
testcase_30 AC 53 ms
9,480 KB
testcase_31 AC 64 ms
9,776 KB
testcase_32 WA -
testcase_33 AC 48 ms
9,112 KB
testcase_34 AC 22 ms
7,764 KB
testcase_35 AC 28 ms
7,820 KB
testcase_36 AC 42 ms
8,396 KB
testcase_37 AC 41 ms
8,540 KB
testcase_38 AC 10 ms
6,444 KB
testcase_39 AC 31 ms
7,660 KB
testcase_40 AC 31 ms
7,648 KB
testcase_41 AC 27 ms
7,320 KB
testcase_42 AC 27 ms
7,368 KB
testcase_43 AC 41 ms
10,008 KB
testcase_44 AC 42 ms
10,036 KB
testcase_45 AC 42 ms
10,140 KB
testcase_46 AC 44 ms
8,376 KB
testcase_47 AC 56 ms
8,880 KB
testcase_48 AC 46 ms
8,696 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(0, n - 1);
      |        ^
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(0, n - 1);
  cout << we << " " << co << endl;
}
0