Submission #82417

#TimeUsernameProblemLanguageResultExecution timeMemory
82417farukkastamonudaFerries (NOI13_ferries)C++14
40 / 40
323 ms20360 KiB
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000009 #define md 1000000007 #define li 100005 #define mp make_pair #define pb push_back #define mid (start+end)/2 using namespace std; int n, m, x, y, z, d[li]; vector<int> v[li], t[li]; priority_queue< pair<int, int> > q; void bfs(){ for(int i = 1; i < n; i ++) d[i] = inf; q.push(mp(0, n)); while(! q.empty()){ pair<int, int> temp = q.top(); q.pop(); int cst = - temp.fi; int seh = temp.se; if(d[seh] != cst) continue; if(seh == 1){ printf("%d\n", cst); exit(0); } for(int i = 0; i < (int)v[seh].size(); i ++){ int ata = v[seh][i]; if( ( int ) t[ata].size() > 0){ int knr = t[ata].back(); t[ata].pop_back(); if(d[ata] > d[seh] + knr){ d[ata] = d[seh] + knr; q.push(mp(- d[ata], ata)); } } } } } int main(){ scanf("%d %d", &n, &m); for(int i = 1; i <= m; i ++){ scanf("%d %d %d", &x, &y, &z); v[y].pb(x); t[x].pb(z); } for(int i = 1;i <= n; i ++){ sort(t[i].begin(), t[i].end()); } bfs(); return 0; }

Compilation message (stderr)

ferries.cpp: In function 'int main()':
ferries.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
ferries.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &x, &y, &z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...