답안 #1019223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1019223 2024-07-10T15:49:06 Z LIF 가장 긴 여행 (IOI23_longesttrip) C++17
40 / 100
948 ms 2568 KB
#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
bool vis[5005];
int dep[5005];
int pre[5005];
bool in_queue[5005];
vector<int> edge[50005];
void dfs(int now)
{
    vis[now] = true;
    for(auto it : edge[now])
    {
        if(vis[it] == true)continue;
        dep[it] = dep[now] + 1;
        pre[it] = now;
        dfs(it);
    }
}
vector<int> longest_trip(int N, int D)
{
    for(int i=0;i<N;i++)edge[i].clear();
    for(int i=1;i<N;i++)
    {
        for(int j=0;j<i;j++)
        {
            vector<int> A;
            vector<int> B;
            A.push_back(i);
            B.push_back(j);
            if(are_connected(A,B) == true)
            {
                edge[i].push_back(j);
                edge[j].push_back(i);
            }
        }
    }
    vector<int> ans;
    for(int i=0;i<N;i++)
    {
        for(int j=0;j<N;j++)pre[j] = -1;
        for(int j=0;j<N;j++)dep[j] = 0;
        for(int j=0;j<N;j++)vis[j] = false;
        dfs(i);
        int maxid = 0;
        int maxn = -1;
        for(int j=0;j<N;j++)
        {
            if(dep[j] > maxn)
            {
                maxn = dep[j];
                maxid = j;
            }
        }
        vector<int> v;
        while(maxid != -1)
        {
            v.push_back(maxid);
            maxid = pre[maxid];
        }
        if(v.size() >= ans.size())
        {
            ans = v;
        }
    }
    return ans;
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1624 KB Output is correct
2 Correct 215 ms 2100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1624 KB Output is correct
2 Correct 27 ms 1620 KB Output is correct
3 Correct 160 ms 1624 KB Output is correct
4 Correct 405 ms 2132 KB Output is correct
5 Correct 868 ms 2096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1624 KB Output is correct
2 Correct 24 ms 1624 KB Output is correct
3 Correct 140 ms 1880 KB Output is correct
4 Correct 424 ms 1872 KB Output is correct
5 Correct 840 ms 2356 KB Output is correct
6 Correct 10 ms 1624 KB Output is correct
7 Correct 27 ms 1368 KB Output is correct
8 Correct 160 ms 1624 KB Output is correct
9 Correct 312 ms 1896 KB Output is correct
10 Correct 840 ms 2568 KB Output is correct
11 Correct 934 ms 2348 KB Output is correct
12 Correct 877 ms 2248 KB Output is correct
13 Correct 874 ms 2232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1624 KB Output is correct
2 Correct 23 ms 1624 KB Output is correct
3 Correct 177 ms 1628 KB Output is correct
4 Correct 442 ms 1880 KB Output is correct
5 Correct 874 ms 2540 KB Output is correct
6 Correct 8 ms 1624 KB Output is correct
7 Correct 23 ms 1624 KB Output is correct
8 Correct 161 ms 1624 KB Output is correct
9 Correct 321 ms 1880 KB Output is correct
10 Correct 877 ms 2020 KB Output is correct
11 Correct 842 ms 2284 KB Output is correct
12 Correct 860 ms 2100 KB Output is correct
13 Correct 886 ms 2464 KB Output is correct
14 Correct 8 ms 1368 KB Output is correct
15 Correct 11 ms 1624 KB Output is correct
16 Correct 46 ms 1624 KB Output is correct
17 Correct 84 ms 1620 KB Output is correct
18 Correct 168 ms 1624 KB Output is correct
19 Correct 281 ms 1628 KB Output is correct
20 Correct 352 ms 1872 KB Output is correct
21 Correct 881 ms 2156 KB Output is correct
22 Correct 838 ms 2000 KB Output is correct
23 Correct 835 ms 2088 KB Output is correct
24 Correct 844 ms 2128 KB Output is correct
25 Correct 13 ms 1624 KB Output is correct
26 Correct 9 ms 1368 KB Output is correct
27 Correct 25 ms 1624 KB Output is correct
28 Correct 22 ms 1368 KB Output is correct
29 Correct 30 ms 1368 KB Output is correct
30 Correct 195 ms 1624 KB Output is correct
31 Correct 198 ms 1868 KB Output is correct
32 Correct 214 ms 1624 KB Output is correct
33 Correct 318 ms 1624 KB Output is correct
34 Correct 327 ms 1624 KB Output is correct
35 Correct 309 ms 1660 KB Output is correct
36 Correct 867 ms 2284 KB Output is correct
37 Correct 862 ms 2300 KB Output is correct
38 Correct 854 ms 2416 KB Output is correct
39 Correct 872 ms 2244 KB Output is correct
40 Correct 830 ms 2092 KB Output is correct
41 Correct 948 ms 1932 KB Output is correct
42 Correct 849 ms 2228 KB Output is correct
43 Correct 841 ms 2208 KB Output is correct
44 Correct 872 ms 2376 KB Output is correct
45 Correct 9 ms 1368 KB Output is correct
46 Correct 10 ms 1624 KB Output is correct
47 Correct 25 ms 1624 KB Output is correct
48 Correct 28 ms 1624 KB Output is correct
49 Correct 22 ms 1368 KB Output is correct
50 Correct 200 ms 2136 KB Output is correct
51 Correct 195 ms 1880 KB Output is correct
52 Correct 202 ms 1624 KB Output is correct
53 Correct 360 ms 1880 KB Output is correct
54 Correct 294 ms 1628 KB Output is correct
55 Correct 324 ms 1648 KB Output is correct
56 Correct 932 ms 2120 KB Output is correct
57 Correct 887 ms 2348 KB Output is correct
58 Correct 841 ms 1904 KB Output is correct
59 Correct 851 ms 2380 KB Output is correct
60 Correct 917 ms 2496 KB Output is correct
61 Correct 937 ms 1760 KB Output is correct
62 Correct 828 ms 1984 KB Output is correct
63 Correct 887 ms 2156 KB Output is correct
64 Correct 898 ms 2144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1624 KB Output is correct
2 Correct 23 ms 1624 KB Output is correct
3 Partially correct 147 ms 1624 KB Output is partially correct
4 Partially correct 446 ms 1896 KB Output is partially correct
5 Partially correct 832 ms 2312 KB Output is partially correct
6 Correct 9 ms 1368 KB Output is correct
7 Correct 25 ms 1624 KB Output is correct
8 Partially correct 132 ms 1624 KB Output is partially correct
9 Partially correct 349 ms 1624 KB Output is partially correct
10 Partially correct 852 ms 2492 KB Output is partially correct
11 Partially correct 902 ms 2356 KB Output is partially correct
12 Partially correct 930 ms 2164 KB Output is partially correct
13 Partially correct 827 ms 2344 KB Output is partially correct
14 Correct 9 ms 1368 KB Output is correct
15 Correct 13 ms 1624 KB Output is correct
16 Incorrect 7 ms 1620 KB Incorrect
17 Halted 0 ms 0 KB -