Submission #1069797

# Submission time Handle Problem Language Result Execution time Memory
1069797 2024-08-22T08:59:54 Z Muhammad_Aneeq Longest Trip (IOI23_longesttrip) C++17
40 / 100
957 ms 1472 KB
#pragma GCC optimize("O2")
#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 (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;
}

Compilation message

longesttrip.cpp: In function 'void dfs(int, int)':
longesttrip.cpp:15:7: warning: variable 'w' set but not used [-Wunused-but-set-variable]
   15 |  bool w=0;
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 197 ms 1036 KB Output is correct
# 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 Correct 157 ms 600 KB Output is correct
4 Correct 409 ms 600 KB Output is correct
5 Correct 904 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 143 ms 344 KB Output is correct
4 Correct 435 ms 848 KB Output is correct
5 Correct 925 ms 1292 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 28 ms 344 KB Output is correct
8 Correct 159 ms 600 KB Output is correct
9 Correct 323 ms 344 KB Output is correct
10 Correct 896 ms 956 KB Output is correct
11 Correct 889 ms 1104 KB Output is correct
12 Correct 791 ms 856 KB Output is correct
13 Correct 855 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 27 ms 344 KB Output is correct
3 Correct 147 ms 700 KB Output is correct
4 Correct 479 ms 600 KB Output is correct
5 Correct 877 ms 728 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 30 ms 344 KB Output is correct
8 Correct 154 ms 344 KB Output is correct
9 Correct 307 ms 344 KB Output is correct
10 Correct 845 ms 856 KB Output is correct
11 Correct 927 ms 1112 KB Output is correct
12 Correct 899 ms 1200 KB Output is correct
13 Correct 895 ms 1320 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 11 ms 344 KB Output is correct
16 Correct 34 ms 344 KB Output is correct
17 Correct 117 ms 344 KB Output is correct
18 Correct 163 ms 344 KB Output is correct
19 Correct 334 ms 436 KB Output is correct
20 Correct 340 ms 464 KB Output is correct
21 Correct 893 ms 928 KB Output is correct
22 Correct 873 ms 1100 KB Output is correct
23 Correct 922 ms 1472 KB Output is correct
24 Correct 885 ms 904 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 8 ms 344 KB Output is correct
27 Correct 29 ms 344 KB Output is correct
28 Correct 24 ms 344 KB Output is correct
29 Correct 21 ms 344 KB Output is correct
30 Correct 193 ms 712 KB Output is correct
31 Correct 194 ms 344 KB Output is correct
32 Correct 186 ms 344 KB Output is correct
33 Correct 302 ms 848 KB Output is correct
34 Correct 321 ms 704 KB Output is correct
35 Correct 300 ms 344 KB Output is correct
36 Correct 897 ms 896 KB Output is correct
37 Correct 893 ms 1092 KB Output is correct
38 Correct 813 ms 960 KB Output is correct
39 Correct 922 ms 1084 KB Output is correct
40 Correct 896 ms 1176 KB Output is correct
41 Correct 835 ms 740 KB Output is correct
42 Correct 844 ms 980 KB Output is correct
43 Correct 831 ms 1204 KB Output is correct
44 Correct 902 ms 988 KB Output is correct
45 Correct 8 ms 344 KB Output is correct
46 Correct 8 ms 344 KB Output is correct
47 Correct 29 ms 344 KB Output is correct
48 Correct 21 ms 344 KB Output is correct
49 Correct 30 ms 344 KB Output is correct
50 Correct 198 ms 344 KB Output is correct
51 Correct 209 ms 692 KB Output is correct
52 Correct 193 ms 600 KB Output is correct
53 Correct 325 ms 856 KB Output is correct
54 Correct 343 ms 472 KB Output is correct
55 Correct 305 ms 344 KB Output is correct
56 Correct 913 ms 852 KB Output is correct
57 Correct 922 ms 964 KB Output is correct
58 Correct 908 ms 1108 KB Output is correct
59 Correct 859 ms 968 KB Output is correct
60 Correct 840 ms 1220 KB Output is correct
61 Correct 873 ms 692 KB Output is correct
62 Correct 910 ms 692 KB Output is correct
63 Correct 852 ms 1212 KB Output is correct
64 Correct 877 ms 1200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 15 ms 344 KB Output is correct
3 Partially correct 146 ms 344 KB Output is partially correct
4 Partially correct 443 ms 716 KB Output is partially correct
5 Partially correct 938 ms 776 KB Output is partially correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 24 ms 344 KB Output is correct
8 Partially correct 166 ms 448 KB Output is partially correct
9 Partially correct 350 ms 344 KB Output is partially correct
10 Partially correct 928 ms 820 KB Output is partially correct
11 Partially correct 899 ms 1116 KB Output is partially correct
12 Partially correct 945 ms 724 KB Output is partially correct
13 Partially correct 957 ms 1104 KB Output is partially correct
14 Correct 9 ms 344 KB Output is correct
15 Correct 11 ms 344 KB Output is correct
16 Incorrect 8 ms 344 KB Incorrect
17 Halted 0 ms 0 KB -