Submission #1069679

# Submission time Handle Problem Language Result Execution time Memory
1069679 2024-08-22T08:06:05 Z Muhammad_Aneeq Longest Trip (IOI23_longesttrip) C++17
40 / 100
969 ms 1436 KB
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <vector>
#include <set>
#include "longesttrip.h"
using namespace std;
int const MAXN=256;
vector<int>nei[MAXN]={};
vector<int>ans;
vector<int>cur;
bool vis[MAXN]={};
void dfs(int u,int p=-1)
{
	vis[u]=1;
	cur.push_back(u);
	bool w=0;
	for (auto i:nei[u])
	{
		if (vis[i])
			continue;
		w=1;
		dfs(i,u);
	}
	if (w==0)
	{
		if (cur.size()>ans.size())
			ans=cur;
	}
	cur.pop_back();
}
vector<int> longest_trip(int N, int D)
{
	ans={};
	cur={};
	for (int i=0;i<N;i++)
		nei[i]={};
	for (int i=0;i<N;i++)
		for (int j=i+1;j<N;j++)
			if (are_connected({i},{j}))
				nei[i].push_back(j),nei[j].push_back(i);
	for (int i=0;i<N;i++)
	{
		for (int j=0;j<N;j++)
			vis[j]=0;
		dfs(i);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 222 ms 824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 164 ms 512 KB Output is correct
4 Correct 450 ms 716 KB Output is correct
5 Correct 966 ms 988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 20 ms 344 KB Output is correct
3 Correct 144 ms 344 KB Output is correct
4 Correct 469 ms 440 KB Output is correct
5 Correct 952 ms 1228 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 163 ms 344 KB Output is correct
9 Correct 350 ms 600 KB Output is correct
10 Correct 942 ms 720 KB Output is correct
11 Correct 897 ms 864 KB Output is correct
12 Correct 918 ms 976 KB Output is correct
13 Correct 920 ms 1032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 33 ms 344 KB Output is correct
3 Correct 164 ms 600 KB Output is correct
4 Correct 442 ms 716 KB Output is correct
5 Correct 954 ms 876 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 164 ms 344 KB Output is correct
9 Correct 323 ms 600 KB Output is correct
10 Correct 912 ms 792 KB Output is correct
11 Correct 930 ms 1084 KB Output is correct
12 Correct 906 ms 1108 KB Output is correct
13 Correct 930 ms 768 KB Output is correct
14 Correct 4 ms 344 KB Output is correct
15 Correct 10 ms 344 KB Output is correct
16 Correct 42 ms 344 KB Output is correct
17 Correct 100 ms 344 KB Output is correct
18 Correct 133 ms 344 KB Output is correct
19 Correct 332 ms 464 KB Output is correct
20 Correct 336 ms 588 KB Output is correct
21 Correct 894 ms 1168 KB Output is correct
22 Correct 953 ms 720 KB Output is correct
23 Correct 907 ms 848 KB Output is correct
24 Correct 857 ms 1400 KB Output is correct
25 Correct 6 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 24 ms 344 KB Output is correct
28 Correct 15 ms 344 KB Output is correct
29 Correct 31 ms 340 KB Output is correct
30 Correct 225 ms 344 KB Output is correct
31 Correct 186 ms 432 KB Output is correct
32 Correct 203 ms 344 KB Output is correct
33 Correct 334 ms 440 KB Output is correct
34 Correct 307 ms 712 KB Output is correct
35 Correct 298 ms 600 KB Output is correct
36 Correct 911 ms 864 KB Output is correct
37 Correct 910 ms 948 KB Output is correct
38 Correct 853 ms 1192 KB Output is correct
39 Correct 853 ms 1172 KB Output is correct
40 Correct 886 ms 920 KB Output is correct
41 Correct 912 ms 720 KB Output is correct
42 Correct 862 ms 656 KB Output is correct
43 Correct 878 ms 1188 KB Output is correct
44 Correct 838 ms 1000 KB Output is correct
45 Correct 6 ms 344 KB Output is correct
46 Correct 9 ms 344 KB Output is correct
47 Correct 23 ms 344 KB Output is correct
48 Correct 23 ms 344 KB Output is correct
49 Correct 36 ms 344 KB Output is correct
50 Correct 221 ms 600 KB Output is correct
51 Correct 208 ms 344 KB Output is correct
52 Correct 176 ms 600 KB Output is correct
53 Correct 350 ms 616 KB Output is correct
54 Correct 307 ms 952 KB Output is correct
55 Correct 308 ms 480 KB Output is correct
56 Correct 884 ms 1232 KB Output is correct
57 Correct 922 ms 956 KB Output is correct
58 Correct 969 ms 940 KB Output is correct
59 Correct 879 ms 1272 KB Output is correct
60 Correct 926 ms 1216 KB Output is correct
61 Correct 895 ms 984 KB Output is correct
62 Correct 911 ms 900 KB Output is correct
63 Correct 934 ms 1116 KB Output is correct
64 Correct 890 ms 1436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 29 ms 344 KB Output is correct
3 Partially correct 145 ms 344 KB Output is partially correct
4 Partially correct 439 ms 344 KB Output is partially correct
5 Partially correct 940 ms 1268 KB Output is partially correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 27 ms 344 KB Output is correct
8 Partially correct 169 ms 852 KB Output is partially correct
9 Partially correct 341 ms 600 KB Output is partially correct
10 Partially correct 956 ms 856 KB Output is partially correct
11 Partially correct 907 ms 460 KB Output is partially correct
12 Partially correct 896 ms 728 KB Output is partially correct
13 Partially correct 916 ms 968 KB Output is partially correct
14 Correct 10 ms 344 KB Output is correct
15 Correct 10 ms 344 KB Output is correct
16 Incorrect 6 ms 344 KB Incorrect
17 Halted 0 ms 0 KB -