제출 #63931

#제출 시각아이디문제언어결과실행 시간메모리
63931ScayreEvacuation plan (IZhO18_plan)C++14
23 / 100
1978 ms90200 KiB
#include <iostream> #include <vector> #include <algorithm> #include <vector> #include <set> #include <cassert> #define mp make_pair #define pb push_back #define ll long long using namespace std; const int MAXN = 1e6; const int INF = 1e9 + 7; vector <pair <int, int> > a[MAXN]; int dp[MAXN]; ll ans = 0; set <pair <int, int> > SS; int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 1; i <= m; i++) { int x, y, w; scanf("%d%d%d", &x, &y, &w); a[x].pb(mp(y, w)); a[y].pb(mp(x, w)); SS.insert(mp(x, y)); SS.insert(mp(y, x)); } int A; scanf("%d", &A); for (int i = 1; i <= n; i++) { dp[i] = INF; } for (int i = 1; i <= A; i++) { int x; scanf("%d", &x); a[0].pb(mp(x, 0)); } set <pair <int, int> > S; S.insert(mp(0, 0)); while (!S.empty()) { int x = S.begin()->second; S.erase(S.begin()); for (int i = 0; i < a[x].size(); i++) { int to = a[x][i].first; int w = a[x][i].second; if (dp[to] > dp[x] + w) { S.erase(mp(dp[to], to)); dp[to] = dp[x] + w; S.insert(mp(dp[to], to)); } } } int Q; scanf("%d", &Q); ll ans = 0; for (int i = 1; i <= Q; i++) { int x, y; scanf("%d%d", &x, &y); ans += min(dp[x], dp[y]); printf("%d\n", min(dp[x], dp[y])); } //cout << ans; return 0; }

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

plan.cpp: In function 'int main()':
plan.cpp:44:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < a[x].size(); i++) {
                   ~~^~~~~~~~~~~~~
plan.cpp:20: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:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &x, &y, &w);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
plan.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &A);
  ~~~~~^~~~~~~~~~
plan.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
plan.cpp:55:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &Q);
  ~~~~~^~~~~~~~~~
plan.cpp:59:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~
#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...