Submission #1088422


Source Code Expand

#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;

vector<P>rinsetu[1000];
int mincost[1000];
int n[1000];
signed main(){
    int a,b,c,d;cin>>a>>b>>c>>d;c--;d--;
    for(int e=0;e<b;e++){
	int f,g,h;scanf("%d%d%d",&f,&g,&h);f--;g--;
	rinsetu[f].push_back(P(h,g));
	rinsetu[g].push_back(P(h,f));
	}
	fill(mincost+1,mincost+a,1<<29);
	fill(n,n+a,1<<29);
	n[d]=0;
	priority_queue<P,vector<P>,greater<P>>Q;
	Q.push(P(0,c));
	while(Q.size()){
	    P t=Q.top();Q.pop();
	    if(t.first>mincost[t.second])continue;
	    for(P i:rinsetu[t.second]){
		if(mincost[i.second]>t.first+i.first){
		    mincost[i.second]=t.first+i.first;
		    Q.push(P(mincost[i.second],i.second));
		    }
		}
	    }
	    while(Q.size())Q.pop();
	    Q.push(P(0,d));
	while(Q.size()){
	    P t=Q.top();Q.pop();
	    if(t.first>n[t.second])continue;
	    for(P i:rinsetu[t.second]){
		if(n[i.second]>t.first+i.first){
		    n[i.second]=t.first+i.first;
		    Q.push(P(n[i.second],i.second));
		    }
		}
	    }
	for(int i=0;i<a;i++){
	    if(mincost[i]==n[i]){cout<<i+1<<endl;return 0;}
	    }
	    puts("-1");
    }

Submission Info

Submission Time
Task C - 身体バランス
User naoki2016
Language C++ (G++ 4.6.4)
Score 0
Code Size 1154 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:18:40: error: ‘Q’ was not declared in this scope
./Main.cpp:18:38: error: ‘>>’ should be ‘> >’ within a nested template argument list
./Main.cpp:23:14: error: range-based-for loops are not allowed in C++98 mode
./Main.cpp:35:14: error: range-based-for loops are not allowed in C++98 mode
./Main.cpp:11:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]