답안 #1069689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069689 2024-08-22T08:15:22 Z Muhammad_Aneeq 가장 긴 여행 (IOI23_longesttrip) C++17
40 / 100
968 ms 1700 KB
#include <vector>
#include <set>
#include "longesttrip.h"
#include <bitset>
using namespace std;
int const MAXN=256;
vector<int>nei[MAXN]={};
vector<int>ans;
vector<int>cur;
bitset<MAXN>vis;
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.clear();
	cur.clear();
	for (int i=0;i<N;i++)
		nei[i].clear();
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 208 ms 1252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 19 ms 344 KB Output is correct
3 Correct 145 ms 440 KB Output is correct
4 Correct 421 ms 596 KB Output is correct
5 Correct 841 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 24 ms 344 KB Output is correct
3 Correct 153 ms 600 KB Output is correct
4 Correct 433 ms 704 KB Output is correct
5 Correct 891 ms 976 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 21 ms 344 KB Output is correct
8 Correct 175 ms 600 KB Output is correct
9 Correct 308 ms 452 KB Output is correct
10 Correct 895 ms 876 KB Output is correct
11 Correct 918 ms 1128 KB Output is correct
12 Correct 901 ms 868 KB Output is correct
13 Correct 957 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 17 ms 344 KB Output is correct
3 Correct 147 ms 436 KB Output is correct
4 Correct 413 ms 716 KB Output is correct
5 Correct 885 ms 992 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 24 ms 344 KB Output is correct
8 Correct 143 ms 344 KB Output is correct
9 Correct 319 ms 344 KB Output is correct
10 Correct 911 ms 696 KB Output is correct
11 Correct 968 ms 716 KB Output is correct
12 Correct 892 ms 1044 KB Output is correct
13 Correct 871 ms 1036 KB Output is correct
14 Correct 7 ms 344 KB Output is correct
15 Correct 13 ms 344 KB Output is correct
16 Correct 45 ms 344 KB Output is correct
17 Correct 91 ms 344 KB Output is correct
18 Correct 147 ms 344 KB Output is correct
19 Correct 311 ms 624 KB Output is correct
20 Correct 316 ms 344 KB Output is correct
21 Correct 886 ms 1040 KB Output is correct
22 Correct 908 ms 812 KB Output is correct
23 Correct 917 ms 904 KB Output is correct
24 Correct 883 ms 980 KB Output is correct
25 Correct 8 ms 596 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 22 ms 344 KB Output is correct
28 Correct 21 ms 344 KB Output is correct
29 Correct 27 ms 344 KB Output is correct
30 Correct 213 ms 344 KB Output is correct
31 Correct 200 ms 664 KB Output is correct
32 Correct 188 ms 344 KB Output is correct
33 Correct 312 ms 600 KB Output is correct
34 Correct 321 ms 600 KB Output is correct
35 Correct 325 ms 464 KB Output is correct
36 Correct 859 ms 848 KB Output is correct
37 Correct 876 ms 1188 KB Output is correct
38 Correct 895 ms 912 KB Output is correct
39 Correct 878 ms 1368 KB Output is correct
40 Correct 868 ms 1044 KB Output is correct
41 Correct 822 ms 976 KB Output is correct
42 Correct 859 ms 960 KB Output is correct
43 Correct 903 ms 1156 KB Output is correct
44 Correct 838 ms 948 KB Output is correct
45 Correct 7 ms 344 KB Output is correct
46 Correct 8 ms 344 KB Output is correct
47 Correct 24 ms 344 KB Output is correct
48 Correct 28 ms 344 KB Output is correct
49 Correct 25 ms 344 KB Output is correct
50 Correct 209 ms 344 KB Output is correct
51 Correct 219 ms 600 KB Output is correct
52 Correct 207 ms 428 KB Output is correct
53 Correct 313 ms 452 KB Output is correct
54 Correct 358 ms 668 KB Output is correct
55 Correct 319 ms 596 KB Output is correct
56 Correct 907 ms 1104 KB Output is correct
57 Correct 870 ms 1552 KB Output is correct
58 Correct 903 ms 1004 KB Output is correct
59 Correct 923 ms 1700 KB Output is correct
60 Correct 925 ms 1184 KB Output is correct
61 Correct 830 ms 764 KB Output is correct
62 Correct 848 ms 756 KB Output is correct
63 Correct 869 ms 1468 KB Output is correct
64 Correct 870 ms 964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 19 ms 344 KB Output is correct
3 Partially correct 132 ms 344 KB Output is partially correct
4 Partially correct 428 ms 344 KB Output is partially correct
5 Partially correct 871 ms 736 KB Output is partially correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Partially correct 157 ms 448 KB Output is partially correct
9 Partially correct 312 ms 704 KB Output is partially correct
10 Partially correct 879 ms 848 KB Output is partially correct
11 Partially correct 914 ms 856 KB Output is partially correct
12 Partially correct 843 ms 1020 KB Output is partially correct
13 Partially correct 879 ms 1116 KB Output is partially correct
14 Correct 6 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 -