제출 #38102

#제출 시각아이디문제언어결과실행 시간메모리
38102nibnalin페리들 (NOI13_ferries)C++14
0 / 40
376 ms26996 KiB
#include <iostream> #include <cstdio> #include <vector> #include <set> using namespace std; const int maxn = int(1e5)+5, inf = int(1e9)+5; int D[maxn]; multiset<int> into[maxn]; vector<int> graph[maxn]; int main(void) { int n, m, a, b, c; scanf("%d%d", &n, &m); for(int i = 0;i < n;i++) D[i] = inf; for(int i = 0;i < m;i++) { scanf("%d%d%d", &a, &b, &c); a--, b--; graph[b].push_back(a); into[a].insert(c); } set<pair<int, int>> Q; D[n-1] = 0; Q.insert({D[n-1], n-1}); while(!Q.empty()) { pair<int, int> top = *Q.begin(); Q.erase(Q.begin()); //cout << top.first << " " << top.second << "\n"; for(auto it: graph[top.second]) { int w = *into[it].rbegin(); if(D[it] > D[top.second]+w) { D[it] = D[top.second]+w; if(D[it] != inf) Q.erase({D[it], it}); into[it].erase(into[it].find(w)); Q.insert({D[it], it}); } } } printf("%d\n", D[0]); }

컴파일 시 표준 에러 (stderr) 메시지

ferries.cpp: In function 'int main()':
ferries.cpp:16:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
                       ^
ferries.cpp:20:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &a, &b, &c);
                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...