답안 #44535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44535 2018-04-03T04:09:09 Z zetapi 관광 (NOI14_sightseeing) C++14
15 / 25
3500 ms 108488 KB
/*
     Contest  :
     Task    :
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define pb  push_back
#define mp  make_pair
#define ll  long long
#define F   first
#define S   second
#define itr ::iterator 
 
typedef pair<int,int> pii;
 
const int MAX=6e5+99;
 
vector<pii> vec[MAX];
 
int V,E,Q,X,Y,Z,res[MAX];
 
void dijkstra()
{
	int tem;
	pii cur;
	priority_queue<pii> pq;
	pq.push(mp(MAX,1));
	res[1]=MAX;
	while(! pq.empty())
	{
		cur=pq.top();
		pq.pop();
		if(cur.first < res[cur.second])
		continue;
		for(auto A:vec[cur.second])
		{
		    tem=min(cur.first,A.second);
			if(tem>res[A.first])
			{
				res[A.first]=tem;
				pq.push(mp(res[A.first],A.first));
			}
		}
	}
	return ;
}
 
signed main()
{
	//ios_base::sync_with_stdio(false);
	/*cin.tie(0);
	cout.tie(0);*/
	
	//cin>>V>>E>>Q;
	scanf("%d %d %d",&V,&E,&Q);
	while(E--)
	{
		scanf("%d %d %d",&X,&Y,&Z);
		vec[X].pb(mp(Y,Z));
		vec[Y].pb(mp(X,Z));
	}
	dijkstra();
	while(Q--)
	{
		scanf("%d",&X);
		printf("%d\n",res[X]);
	}
    return 0;
}

Compilation message

sightseeing.cpp: In function 'int main()':
sightseeing.cpp:57:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&V,&E,&Q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
sightseeing.cpp:60:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&X,&Y,&Z);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
sightseeing.cpp:67:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&X);
   ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 14456 KB Output is correct
2 Correct 14 ms 14536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 14620 KB Output is correct
2 Correct 14 ms 14668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 16660 KB Output is correct
2 Correct 56 ms 16660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3525 ms 108488 KB Time limit exceeded
2 Halted 0 ms 0 KB -