神奇的S组T1民间数据+做法
  • 板块灌水区
  • 楼主xiaoshui
  • 当前回复1
  • 已保存回复1
  • 发布时间2022/10/30 13:13
  • 上次更新2023/10/27 04:53:27
查看原帖
神奇的S组T1民间数据+做法
381935
xiaoshui楼主2022/10/30 13:13

rt,菜到离谱T1就不会正解/kk,然后打了个暴搜(真的很暴力,只能过k=0的点,n=2500、m=10000也肯定过不去,结果你谷上50分?!关键InfOJ上也45,求原理

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,k,a[3100],ans;
vector<int> G[11000]; 
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		res=res*10+ch-'0';
		ch=getchar();
	}
	return res*f;
}
bool vis[3100];
void dfs(int now,ll num,int dep){
	if(dep==4){
		for(int i:G[now]){
			if(i==1){
			 	ans=max(ans,num);
			 	return;
			}
		}
		return;
	}
	for(int i:G[now]){
		if(vis[i]||i==1)continue;
		vis[i]=1;
		dfs(i,num+a[i],dep+1);
		vis[i]=0;
	}
	
}
int main(){
	//freopen("holiday.in","r",stdin);
	//freopen("holiday.out","w",stdout);
	n=read(),m=read(),k=read();
	for(int i=2;i<=n;i++)a[i]=read();
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs(1,0,0);
	cout<<ans<<endl;
	return 0;
}
2022/10/30 13:13
加载中...