Why MLE+TLE?
查看原帖
Why MLE+TLE?
575655
Chtholly_is_cute楼主2023/5/28 16:05

MLE on #1,2

TLE on #3,4,6,7,8,9,10

code:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,vector<int> >mp;
int maxn,vis[299998];
void dfs(int x){
	if(vis[x])return;
	maxn=max(maxn,x);
	for(int i=0;i<mp[x].size();i++){
		dfs(mp[x][i]);
	}
} 
int main(){
	int n,m;
	cin>>n>>m;
	int u,v;
	for(int i=0;i<m;i++){
		cin>>u>>v;
		mp[u].push_back(v);
	}
	for(int i=1;i<=n;++i){
		memset(vis,0,sizeof(vis));
		maxn=-29999998;
		dfs(i);
		cout<<maxn<<' ';
	} 
}
2023/5/28 16:05
加载中...