Notice: Undefined index: name in /usr/www/lib/views/home/viewtitle.html on line 188
-阅读程序 第 18 题
# include<bits/stdc++.h>

using namespace std;
typedef long long int_t;

int_t dis[1<<18][18];

struct E {
	int_t to,w;
	E(int_t to, int_t w):to(to),w(w) {}
};

vector<E> G[20];

int_t dfs(int_t rt, int_t vised, int_t n) {
	if(rt ==n-1) return 0;
	if(dis[vised][rt]) return dis[vised][rt];
	dis[vised][rt]=998244353;
	for(E e : G[rt]) {
		int_t to=e.to, w= e.w;
		if((1<<to) & vised) continue;
		dis[vised][rt]=max(dis[vised][rt],dfs(to,vised|(1<<to),n)+w);
	}
	return dis[vised][rt];
}

int main() {
	int_t n,m;	cin>> n>> m;
	while(m--) {
		int_t u,v,w;cin>>u>>v>> w;
		G[u].push_back(E(v,w));
	}
	cout<<dfs(0,1,n);
}
假设输入的n是不超过18的正整数,w不会超过10000完成下面的判断题和单选题: [image259]
● 判断题
第 1 题 此代码可以在noip标准F编译。( )
第 2 题 此代码能处理重边与自环。( )
第 3 题 此算法可以被dijkstra 替代。( )
● 单选题
第 4 题 以下说法错误的是( )
第 5 题 若以左侧数据为输入数据,则答案为( )
第 6 题 此代码的时间复杂度为( )

解答部分以后会开放。