Submission #9278

#TimeUsernameProblemLanguageResultExecution timeMemory
9278YoonYour life (kriii2_Y)C++98
Compilation error
0 ms0 KiB
#include <stdio.h> #include <vector> #include <queue> using namespace std; int N,M; vector<pair<int,int>> adj[100010]; vector<int> dijkstra(int src) { vector<int> dist(N+1,1234567890); dist[src]=0; priority_queue<pair<int,int>> pq; pq.push(make_pair(0,src)); while(!pq.empty()){ int cost=-pq.top().first; int here=pq.top().second; pq.pop(); if(dist[here]<cost)continue; for(int i=0;i<adj[here].size();++i){ int there=adj[here][i].first; int nextDist=cost+adj[here][i].second; if(dist[there]>nextDist){ dist[there]=nextDist; pq.push(make_pair(-nextDist,there)); } } } return dist; } int main() { int i,j,a,b; scanf("%d %d",&N,&M); for(i=1;i<=M;i++){ scanf("%d %d",&a,&b); adj[a].push_back(make_pair(b,1)); } vector<int> shortest=dijkstra(1); int ret=shortest[N]; if(ret==1234567899)printf("-1\n"); else printf("%d\n",ret); return 0; }

Compilation message (stderr)

Y.cpp:6:20: error: '>>' should be '> >' within a nested template argument list
Y.cpp: In function 'std::vector<int> dijkstra(int)':
Y.cpp:11:29: error: '>>' should be '> >' within a nested template argument list
Y.cpp:18:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
Y.cpp: In function 'int main()':
Y.cpp:31:8: warning: unused variable 'j' [-Wunused-variable]
Y.cpp:32:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
Y.cpp:34:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]