競プロC++ dijkstra法

背景
投稿者投稿者Johannいいね1お気に入り登録
プレイ回数735難易度(3.1) 180秒 英語
競プロで早く打てるようになりたいC++er向け
自分の手ぐせも込みで早く打ちたいから作りました。
そういった理由から別の方には向かないかもしれません

関連タイピング

問題文

ふりがな非表示 ふりがな表示

(#include <iostream>)

#include <iostream>

(#include <vector>)

#include <vector>

(#include <queue>)

#include <queue>

(using namespace std;)

using namespace std;

(using ll = long long;)

using ll = long long;

(struct Edge{)

struct Edge{

(int to;)

int to;

(ll weight;)

ll weight;

(Edge(int t, ll w): to(t), weight(w) {})

Edge(int t, ll w): to(t), weight(w) {}

(int main(){)

int main(){

(int n, m;)

int n, m;

(cin >> n >> m;)

cin >> n >> m;

(for(int i = 0; i < m; ++i){)

for(int i = 0; i < m; ++i){

(int a, b;)

int a, b;

(ll c;)

ll c;

(cin >> a >> b >> c;)

cin >> a >> b >> c;

(--a;)

--a;

(--b;)

--b;

(g[a].push_back(Edge(b, c));)

g[a].push_back(Edge(b, c));

(g[b].push_back(Edge(a, c));)

g[b].push_back(Edge(a, c));

など

(priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;)

priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;

(pq.push({0, 0});)

pq.push({0, 0});

(const ll INF = 1ll << 60;)

const ll INF = 1ll << 60;

(vector<ll> dist(n, INF);)

vector<ll> dist(n, INF);

(dist[0] = 0;)

dist[0] = 0;

(while(!pq.empty()){)

while(!pq.empty()){

(auto [d, v] = pq.top();)

auto [d, v] = pq.top();

(pq.pop();)

pq.pop();

(if(dist[v] != d) continue;)

if(dist[v] != d) continue;

(for(auto ne: g[v]){)

for(auto ne: g[v]){

(int nv = ne.to;)

int nv = ne.to;

(if(dist[nv] > dist[v] + ne.weight){)

if(dist[nv] > dist[v] + ne.weight){

(dist[nv] = dist[v] + ne.weight;)

dist[nv] = dist[v] + ne.weight;

(pq.push({dist[nv], nv});)

pq.push({dist[nv], nv});

(ll res = dist.back();)

ll res = dist.back();

(if(res == INF) res = -1;)

if(res == INF) res = -1;

(cout << res << endl;)

cout << res << endl;

(return 0;)

return 0;

問題文を全て表示 一部のみ表示 誤字・脱字等の報告