제출 #205775

#제출 시각아이디문제언어결과실행 시간메모리
205775ly20Toll (BOI17_toll)C++17
10 / 100
136 ms31480 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 512345; const long long INF = 1123456789012; long long v[MAXN]; vector <int> grafo[MAXN]; vector <long long> peso[MAXN]; long long dist[MAXN]; int grau[MAXN]; int main() { int k, n, m, o; scanf("%d %d %d %d", &k, &n, &m, &o); for(int i = 0; i < m; i++) { int a, b; long long p; scanf("%d %d", &a, &b); grau[b]++; scanf("%lld", &p); grafo[a].push_back(b); peso[a].push_back(p); } for(int i = 0; i < n; i++) dist[i] = INF; dist[0] = 0LL; queue <int> fila; for(int i = 0; i < n; i++) if(grau[i] == 0) fila.push(i); while(!fila.empty()) { int cur = fila.front(); fila.pop(); for(int i = 0; i < grafo[cur].size(); i++) { int viz = grafo[cur][i]; long long p = peso[cur][i]; dist[viz] = min(dist[viz], dist[cur] + p); grau[viz]--; if(grau[viz] == 0) fila.push(viz); } } for(int i = 0; i < o; i++) { int a, b; scanf("%d %d", &a, &b); if(dist[b] >= INF) printf("-1\n"); else printf("%lld\n", dist[b]); } return 0; }

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

toll.cpp: In function 'int main()':
toll.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < grafo[cur].size(); i++) {
                  ~~^~~~~~~~~~~~~~~~~~~
toll.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d", &k, &n, &m, &o);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toll.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~~
toll.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &p);
   ~~~~~^~~~~~~~~~~~
toll.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...