Submission #848531

# Submission time Handle Problem Language Result Execution time Memory
848531 2023-09-12T20:46:15 Z Edu175 Longest Trip (IOI23_longesttrip) C++17
5 / 100
880 ms 1632 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){
		g[i].clear();
	}
	res.clear();
	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){
		fore(i,0,n)vis[i]=0;
		p.clear();
		dfs(x);
		if(SZ(p)>SZ(res))res=p;
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 188 ms 1632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Correct 122 ms 600 KB Output is correct
4 Correct 403 ms 1360 KB Output is correct
5 Correct 880 ms 1552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 600 KB Output is correct
2 Correct 26 ms 344 KB Output is correct
3 Correct 132 ms 856 KB Output is correct
4 Correct 369 ms 964 KB Output is correct
5 Correct 832 ms 1368 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 24 ms 344 KB Output is correct
3 Correct 130 ms 344 KB Output is correct
4 Correct 385 ms 1484 KB Output is correct
5 Correct 818 ms 1360 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Partially correct 121 ms 600 KB Output is partially correct
4 Partially correct 426 ms 888 KB Output is partially correct
5 Partially correct 806 ms 1548 KB Output is partially correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -