Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为啥过不了T-T

Posted by 20211045 at 2023-04-04 22:28:12 on Problem 1797
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int map[1010][1010];
int clost[1010];
bool is[1010];
int main()
{
	int n, m,s,e,w,t;
	cin >> t;
	while (t) 
	{
		cin >> n >> m;
		memset(map, 0, sizeof(map));
		memset(is, 0, sizeof(is));
		for (int i = 0; i < m; ++i)
		{
			cin >> s >> e >> w;
			map[s][e] = w;
			map[e][s] = w;
		}
		for (int i = 1; i <= n; ++i)
			clost[i] = map[1][i];
		for (int i = 1; i <= n; ++i)
		{
			int max = -1,bj=0;
			for(int j=1;j<=n;++j)
				if (!is[j] && max < clost[j])
				{
					max = clost[j];
					bj = j;
				}
			is[bj] = 1;
			for (int j = 1; j <= n; ++j)
				if ((min(map[bj][j],clost[bj])>clost[j])&&(!is[j]))
					clost[j] = min(map[bj][j] , clost[bj]);
		}
		printf("Scenario #%d:\n", t);
		printf("%d\n\n", clost[n]);
		t--;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator