Submission #1069684

# Submission time Handle Problem Language Result Execution time Memory
1069684 2024-08-22T08:10:37 Z Muhammad_Aneeq Longest Trip (IOI23_longesttrip) C++17
15 / 100
1000 ms 592 KB
#include <vector>
#include <set>
#include "longesttrip.h"
using namespace std;
int const MAXN=256;
bool nei[MAXN][MAXN]={};
vector<int>ans;
vector<int>cur;
bool vis[MAXN]={};
int n;
void dfs(int u)
{
	vis[u]=1;
	cur.push_back(u);
	bool w=0;
	for (int i=0;i<n;i++)
	{
		if (nei[i][u]&&!vis[i])
			dfs(i);
	}
	if (w==0)
	{
		if (cur.size()>ans.size())
			ans=cur;
	}
	cur.pop_back();
}
vector<int> longest_trip(int N, int D)
{
	n=N;
	ans={};
	cur={};
	for (int i=0;i<N;i++)
		for (int j=0;j<N;j++)
			nei[i][j]=0;
	for (int i=0;i<N;i++)
		for (int j=i+1;j<N;j++)
			if (are_connected({i},{j}))
				nei[i][j]=nei[j][i]=1;
	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 240 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Correct 135 ms 344 KB Output is correct
4 Correct 429 ms 344 KB Output is correct
5 Correct 903 ms 592 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 Correct 146 ms 340 KB Output is correct
4 Correct 433 ms 344 KB Output is correct
5 Correct 951 ms 464 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 138 ms 344 KB Output is correct
9 Correct 354 ms 344 KB Output is correct
10 Correct 911 ms 592 KB Output is correct
11 Correct 945 ms 468 KB Output is correct
12 Correct 908 ms 464 KB Output is correct
13 Correct 874 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 24 ms 344 KB Output is correct
3 Correct 156 ms 344 KB Output is correct
4 Correct 370 ms 436 KB Output is correct
5 Correct 844 ms 472 KB Output is correct
6 Correct 11 ms 344 KB Output is correct
7 Correct 20 ms 344 KB Output is correct
8 Correct 144 ms 344 KB Output is correct
9 Correct 369 ms 424 KB Output is correct
10 Correct 914 ms 592 KB Output is correct
11 Correct 941 ms 464 KB Output is correct
12 Correct 932 ms 464 KB Output is correct
13 Correct 906 ms 468 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 11 ms 344 KB Output is correct
16 Correct 29 ms 344 KB Output is correct
17 Correct 93 ms 344 KB Output is correct
18 Correct 165 ms 344 KB Output is correct
19 Correct 335 ms 428 KB Output is correct
20 Correct 336 ms 344 KB Output is correct
21 Correct 986 ms 468 KB Output is correct
22 Correct 979 ms 460 KB Output is correct
23 Execution timed out 1070 ms 464 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 29 ms 344 KB Output is correct
3 Partially correct 158 ms 344 KB Output is partially correct
4 Partially correct 464 ms 344 KB Output is partially correct
5 Partially correct 955 ms 464 KB Output is partially correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Partially correct 154 ms 344 KB Output is partially correct
9 Partially correct 356 ms 432 KB Output is partially correct
10 Partially correct 917 ms 460 KB Output is partially correct
11 Partially correct 922 ms 464 KB Output is partially correct
12 Partially correct 914 ms 464 KB Output is partially correct
13 Partially correct 961 ms 468 KB Output is partially correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 13 ms 344 KB Output is correct
16 Incorrect 6 ms 344 KB Incorrect
17 Halted 0 ms 0 KB -