Submission #20843


Source Code Expand

#include<queue>
#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

struct edge{ int v,cost; };

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<edge> G[10000];
	rep(i,m){
		int u,v,cost; scanf("%d%d%d",&u,&v,&cost);
		G[u].push_back((edge){v,cost});
		G[v].push_back((edge){u,cost});
	}

	static int d[10000][28];
	rep(u,n) rep(k,28) d[u][k]=INF;
	d[0][0]=0;

	priority_queue< pair< int,pair<int,int> > > Q;
	Q.push(make_pair(0,make_pair(0,0)));
	while(!Q.empty()){
		int d_now=-Q.top().first,u=Q.top().second.first,k=Q.top().second.second; Q.pop();

		if(d[u][k]<d_now || u==n-1) continue;

		rep(i,G[u].size()){
			int v=G[u][i].v,cost=G[u][i].cost;
			int d_next=d[u][k]+cost;
			int k_next=(k+cost)%28;
			if(d[v][k_next]>d_next){
				d[v][k_next]=d_next;
				Q.push(make_pair(-d_next,make_pair(v,k_next)));
			}
		}
	}

	int ans=INF;
	rep(k,28) if(k%4==0 || k%7==0) ans=min(ans,d[n-1][k]);
	printf("%d\n",ans);

	return 0;
}

Submission Info

Submission Time
Task E - 会場への道
User fura2
Language C++ (G++ 4.6.4)
Score 100
Code Size 1033 Byte
Status AC
Exec Time 49 ms
Memory 2260 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:16:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name sub1 sub2
Score / Max Score 30 / 30 70 / 70
Status
AC × 15
AC × 26
Set Name Test Cases
sub1 sub1/input_0.txt, sub1/input_1.txt, sub1/input_2.txt, sub1/input_20.txt, sub1/input_21.txt, sub1/input_22.txt, sub1/input_23.txt, sub1/input_24.txt, sub1/input_3.txt, sub1/input_4.txt, sub1/input_5.txt, sub1/input_6.txt, sub1/input_7.txt, sub1/input_8.txt, sub1/input_9.txt
sub2 sub2/input_0.txt, sub2/input_1.txt, sub2/input_10.txt, sub2/input_11.txt, sub2/input_12.txt, sub2/input_13.txt, sub2/input_14.txt, sub2/input_15.txt, sub2/input_16.txt, sub2/input_17.txt, sub2/input_18.txt, sub2/input_19.txt, sub2/input_2.txt, sub2/input_20.txt, sub2/input_21.txt, sub2/input_22.txt, sub2/input_23.txt, sub2/input_24.txt, sub2/input_25.txt, sub2/input_3.txt, sub2/input_4.txt, sub2/input_5.txt, sub2/input_6.txt, sub2/input_7.txt, sub2/input_8.txt, sub2/input_9.txt
Case Name Status Exec Time Memory
sub1/input_0.txt AC 23 ms 1072 KB
sub1/input_1.txt AC 20 ms 1036 KB
sub1/input_2.txt AC 21 ms 1036 KB
sub1/input_20.txt AC 24 ms 1152 KB
sub1/input_21.txt AC 22 ms 1028 KB
sub1/input_22.txt AC 24 ms 1120 KB
sub1/input_23.txt AC 20 ms 1028 KB
sub1/input_24.txt AC 20 ms 1016 KB
sub1/input_3.txt AC 22 ms 944 KB
sub1/input_4.txt AC 21 ms 916 KB
sub1/input_5.txt AC 22 ms 912 KB
sub1/input_6.txt AC 21 ms 1032 KB
sub1/input_7.txt AC 21 ms 1032 KB
sub1/input_8.txt AC 21 ms 1036 KB
sub1/input_9.txt AC 22 ms 1024 KB
sub2/input_0.txt AC 26 ms 1032 KB
sub2/input_1.txt AC 22 ms 1028 KB
sub2/input_10.txt AC 25 ms 1164 KB
sub2/input_11.txt AC 49 ms 2184 KB
sub2/input_12.txt AC 45 ms 2176 KB
sub2/input_13.txt AC 24 ms 1168 KB
sub2/input_14.txt AC 37 ms 1616 KB
sub2/input_15.txt AC 44 ms 2172 KB
sub2/input_16.txt AC 46 ms 2260 KB
sub2/input_17.txt AC 44 ms 2168 KB
sub2/input_18.txt AC 44 ms 2172 KB
sub2/input_19.txt AC 44 ms 1856 KB
sub2/input_2.txt AC 21 ms 912 KB
sub2/input_20.txt AC 26 ms 1160 KB
sub2/input_21.txt AC 22 ms 1036 KB
sub2/input_22.txt AC 24 ms 1040 KB
sub2/input_23.txt AC 22 ms 1036 KB
sub2/input_24.txt AC 22 ms 976 KB
sub2/input_25.txt AC 24 ms 1168 KB
sub2/input_3.txt AC 23 ms 1032 KB
sub2/input_4.txt AC 23 ms 1108 KB
sub2/input_5.txt AC 37 ms 900 KB
sub2/input_6.txt AC 21 ms 1032 KB
sub2/input_7.txt AC 22 ms 908 KB
sub2/input_8.txt AC 20 ms 1036 KB
sub2/input_9.txt AC 21 ms 1032 KB