제출 #168914

#제출 시각아이디문제언어결과실행 시간메모리
168914YottaByteEvacuation plan (IZhO18_plan)C++14
10 / 100
5 ms816 KiB
#include <iostream> #include <queue> #include <vector> using namespace std; #define ll long long #define sz(x) (int)x.size() #define pii pair < int, int > #define endl "\n" #define METH ios::sync_with_stdio(0); cin.tie(0); #define BEGIN cout << "BEGIN" << endl; #define END cout << "END" << endl; const int N = 1e3; const int mod = 1e9 + 7; /// ANOTHER HASH MOD: 228228227 const int prime = 29; /// ANOTHER HASH PRIME: 997 const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8); int n, m, k, q; vector < int > bad, dist(N + 1, INF); vector < pii > g[N + 1], querry; inline void purify() { } inline void precalc() { } inline void read() { scanf("%d %d", &n, &m); for (int i = 1; i <= m; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); g[a].push_back({b, c}); g[b].push_back({a, c}); } scanf("%d", &k); for (int i = 1; i <= k; i++) { int a; scanf("%d", &a); bad.push_back(a); } scanf("%d", &q); querry.push_back({0, 0}); for (int i = 1; i <= q; i++) { int a, b; scanf("%d %d", &a, &b); querry.push_back({a, b}); } } void dij(int cur) { priority_queue < pii > pq; pq.push({0, cur}); dist[cur] = 0; while (pq.size()) { cur = pq.top().second; int d = -pq.top().first; pq.pop(); if (d > dist[cur]) { continue; } for (pii i : g[cur]) { int u = i.first; int len = i.second; if (dist[cur] + len < dist[u]) { dist[u] = dist[cur] + len; pq.push({-dist[u], u}); } } } } inline void solve() { if (n <= N && m <= N && q <= N) { for (int i : bad) { dij(i); } for (int i = 1; i <= q; i++) { pii j = querry[i]; printf("%d\n", min(dist[j.first], dist[j.second])); } } } int main() { int t; //scanf("%d", &t); t = 1; //precalc(); while (t--) { //purify(); read(); solve(); } }

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

plan.cpp: In function 'void read()':
plan.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
plan.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &a, &b, &c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
plan.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &k);
  ~~~~~^~~~~~~~~~
plan.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a);
   ~~~~~^~~~~~~~~~
plan.cpp:47:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
  ~~~~~^~~~~~~~~~
plan.cpp:51: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...