제출 #90396

#제출 시각아이디문제언어결과실행 시간메모리
90396inomEvacuation plan (IZhO18_plan)C++14
23 / 100
692 ms31744 KiB
#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define int long long

using namespace std;

const int N = 100100;
const int INF = 1e15;

int n, m, k, q;
int a[N], d[N];
set<pair<int, int>> st;
vector<pair<int, int>> verr[N];

signed main() {
	scanf("%lld %lld", &n, &m);
	for (int i = 1; i <= m; i++) {
		int x, y, cost;
		scanf("%lld %lld %lld", &x, &y, &cost);
		verr[x].pb({y, cost}); verr[y].pb({x, cost});
	}
	fill(d + 1, d + 1 + n, INF);
	scanf("%lld", &k);
	for (int i = 1; i <= k; i++) {
		scanf("%lld", &a[i]);
		d[a[i]] = 0;
		st.insert({0, a[i]});
	}
	while (!st.empty()) {
		int x = st.begin()->se;
		st.erase(st.begin());
		for (auto i: verr[x]) {
			int to = i.fi, len = i.se;
			if (d[x] + len < d[to]) {
				st.erase({d[to], to});
				d[to] = d[x] + len;
				st.insert({d[to], to});
			}
		}
	}
	scanf("%lld", &q);
	while (q--) {
		int x, y;
		scanf("%lld %lld", &x, &y);
		printf("%lld\n", min(d[x], d[y]));
	}
	return 0;
}

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

plan.cpp: In function 'int main()':
plan.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
plan.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld", &x, &y, &cost);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plan.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &k);
  ~~~~~^~~~~~~~~~~~
plan.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &a[i]);
   ~~~~~^~~~~~~~~~~~~~~
plan.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &q);
  ~~~~~^~~~~~~~~~~~
plan.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld", &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...