Submission #848530

# Submission time Handle Problem Language Result Execution time Memory
848530 2023-09-12T20:42:00 Z Edu175 Longest Trip (IOI23_longesttrip) C++17
0 / 100
24 ms 1212 KB
#include "longesttrip.h"
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(ll i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define imp(v) for(auto messi:v)cout<<messi<<" "; cout<<"\n"
using namespace std;
typedef int ll;
typedef pair<ll,ll> ii;
#define ask are_connected
const ll MAXN=300;

vector<ll>g[MAXN];
ll n,d;

vector<ll>res;
vector<ll>p;
ll vis[MAXN];
void dfs(ll x){
	vis[x]=1;
	p.pb(x);
	for(auto y:g[x])if(!vis[y])dfs(y);
}

vector<int> longest_trip(int N, int D){
	n=N,d=D;
	fore(i,0,n)fore(j,i+1,n){
		if(ask({i},{j}))g[i].pb(j),g[j].pb(i);
	}
	fore(x,0,n){
		mset(vis,0);
		p.clear();
		dfs(x);
		if(SZ(p)>SZ(res))res=p;
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 600 KB Output is correct
2 Incorrect 23 ms 728 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 856 KB Output is correct
2 Incorrect 22 ms 948 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 600 KB Output is correct
2 Incorrect 24 ms 716 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 860 KB Output is correct
2 Incorrect 23 ms 1212 KB Incorrect
3 Halted 0 ms 0 KB -