求助(悬棺)
查看原帖
求助(悬棺)
1462349
aqtw_qidong_b6lyb楼主2024/11/28 21:44

题目

我的代码:

#include<iostream>

#include<cmath>

using namespace std;

int n,m;

int s[20000][20000];

bool book[20000][20000];

int maxx;

int tot;

void bdfs(int now){
	
	if(now == n){
		
		maxx=max(maxx,tot);
		
		return;
		
	}
	
	for(int i=1;i<=n;i++){
		
		if(book[now][i]){
			
			tot += s[now][i];
			
			book[now][i]=false;
			
			bdfs(i);
			
			tot -= s[now][i];
			
			book[now][i]=true;
			
		}
			
	}
	
	return;
	
}
int main(){
	
	cin >>n>>m;	
	
	for(int i=1;i<=m;i++){
		int a,b,c;
		
		cin >>a>>b>>c;
		
		s[a][b]=c;
		
		book[a][b]=true;
		
	}
	
	bdfs(1);
	
	cout<<maxx;
	
	return 0;
	
} 

谁能帮忙看一下,求求了

2024/11/28 21:44
加载中...