제출 #91985

#제출 시각아이디문제언어결과실행 시간메모리
91985emil_physmathEvacuation plan (IZhO18_plan)C++17
0 / 100
184 ms10612 KiB
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
const int INF=200000000;
const int MAXN=100005;

vector<pair<int, int> > nei[MAXN];
int dist[MAXN], p[MAXN];

int main()
{
	int n, m, k, Q;
	cin>>n>>m;
	for (int i=0; i<m; i++)
	{
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		nei[u].push_back(make_pair(v, w));
		nei[v].push_back(make_pair(u, w));
	}
	priority_queue< pair<int,int> > q;
	for (int u=1; u<=n; u++) dist[u]=INF;
	cin>>k;
	for (int i=0; i<k; i++)
	{
		int s;
		scanf("%d", &s);
		dist[s]=0;
		q.push(make_pair(0, s));
	}
	while (!q.empty()) {
		int v=q.top().second, cur_d=-q.top().first;
		q.pop();
		if (cur_d > dist[v])  continue;
		for (int j=0; j<nei[v].size(); ++j) {
			int to=nei[v][j].first,
				len=nei[v][j].second;
			if (dist[v]+len<dist[to]) {
				dist[to]=dist[v]+len;
				p[to]=v;
				q.push(make_pair(-dist[to], to));
			}
		}
	}
	cin>>Q;
	while (Q--)
	{
		int s, e;
		scanf("%d%d", &s, &e);
		printf("%d\n", max(dist[s], dist[e]));
	}

	char I;
	cin >> I;
	return 0;
}

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

plan.cpp: In function 'int main()':
plan.cpp:37:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j=0; j<nei[v].size(); ++j) {
                 ~^~~~~~~~~~~~~~
plan.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &u, &v, &w);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
plan.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &s);
   ~~~~~^~~~~~~~~~
plan.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &s, &e);
   ~~~~~^~~~~~~~~~~~~~~~
#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...