답안 #994866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994866 2024-06-08T07:52:19 Z 김은성(#10865) 가장 긴 여행 (IOI23_longesttrip) C++17
40 / 100
948 ms 1364 KB
#include "longesttrip.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[299];
bool ch[299];
vector<int> path;
void dfs(int v){
    ch[v] = 1;
    path.push_back(v);
    int i;
    for(i=0; i<graph[v].size(); i++){
        int u = graph[v][i];
        if(!ch[u]){
            dfs(u);
            return;
        }
    }
}

std::vector<int> longest_trip(int N, int D){
    int i, j;
    for(i=0; i<N; i++){
        graph[i].clear();
        ch[i] = 0;
    }
    for(i=0; i<N; i++){
        for(j=i+1; j<N; j++){
            if(are_connected({i}, {j})){
                graph[i].push_back(j);
                graph[j].push_back(i);
            }
        }
    }
    vector<int> ret;
    for(i=0; i<N; i++){
        path.clear();
        for(int j=0; j<N; j++)
            ch[j] = 0;
        dfs(i);
        if(path.size() > ret.size())
            ret = path;
    }
    return ret;
}

Compilation message

longesttrip.cpp: In function 'void dfs(int)':
longesttrip.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(i=0; i<graph[v].size(); i++){
      |              ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 219 ms 752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Correct 139 ms 448 KB Output is correct
4 Correct 427 ms 344 KB Output is correct
5 Correct 856 ms 948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 184 ms 456 KB Output is correct
4 Correct 401 ms 712 KB Output is correct
5 Correct 835 ms 884 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 23 ms 344 KB Output is correct
8 Correct 145 ms 344 KB Output is correct
9 Correct 296 ms 344 KB Output is correct
10 Correct 838 ms 864 KB Output is correct
11 Correct 878 ms 864 KB Output is correct
12 Correct 889 ms 732 KB Output is correct
13 Correct 812 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 36 ms 344 KB Output is correct
3 Correct 138 ms 340 KB Output is correct
4 Correct 444 ms 344 KB Output is correct
5 Correct 876 ms 764 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 156 ms 444 KB Output is correct
9 Correct 314 ms 592 KB Output is correct
10 Correct 831 ms 844 KB Output is correct
11 Correct 871 ms 1060 KB Output is correct
12 Correct 852 ms 976 KB Output is correct
13 Correct 886 ms 980 KB Output is correct
14 Correct 7 ms 344 KB Output is correct
15 Correct 11 ms 344 KB Output is correct
16 Correct 35 ms 344 KB Output is correct
17 Correct 87 ms 344 KB Output is correct
18 Correct 150 ms 344 KB Output is correct
19 Correct 294 ms 344 KB Output is correct
20 Correct 308 ms 600 KB Output is correct
21 Correct 854 ms 864 KB Output is correct
22 Correct 845 ms 896 KB Output is correct
23 Correct 808 ms 980 KB Output is correct
24 Correct 824 ms 992 KB Output is correct
25 Correct 8 ms 344 KB Output is correct
26 Correct 8 ms 344 KB Output is correct
27 Correct 22 ms 344 KB Output is correct
28 Correct 22 ms 344 KB Output is correct
29 Correct 29 ms 344 KB Output is correct
30 Correct 201 ms 456 KB Output is correct
31 Correct 176 ms 444 KB Output is correct
32 Correct 192 ms 700 KB Output is correct
33 Correct 309 ms 720 KB Output is correct
34 Correct 283 ms 344 KB Output is correct
35 Correct 305 ms 692 KB Output is correct
36 Correct 828 ms 724 KB Output is correct
37 Correct 772 ms 876 KB Output is correct
38 Correct 789 ms 944 KB Output is correct
39 Correct 790 ms 1132 KB Output is correct
40 Correct 711 ms 1360 KB Output is correct
41 Correct 728 ms 520 KB Output is correct
42 Correct 863 ms 780 KB Output is correct
43 Correct 808 ms 1236 KB Output is correct
44 Correct 872 ms 1104 KB Output is correct
45 Correct 7 ms 344 KB Output is correct
46 Correct 9 ms 344 KB Output is correct
47 Correct 21 ms 344 KB Output is correct
48 Correct 19 ms 344 KB Output is correct
49 Correct 27 ms 344 KB Output is correct
50 Correct 189 ms 344 KB Output is correct
51 Correct 200 ms 344 KB Output is correct
52 Correct 210 ms 344 KB Output is correct
53 Correct 321 ms 344 KB Output is correct
54 Correct 332 ms 468 KB Output is correct
55 Correct 328 ms 716 KB Output is correct
56 Correct 848 ms 956 KB Output is correct
57 Correct 812 ms 944 KB Output is correct
58 Correct 948 ms 964 KB Output is correct
59 Correct 836 ms 1212 KB Output is correct
60 Correct 869 ms 1304 KB Output is correct
61 Correct 852 ms 588 KB Output is correct
62 Correct 876 ms 692 KB Output is correct
63 Correct 866 ms 920 KB Output is correct
64 Correct 882 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Partially correct 180 ms 600 KB Output is partially correct
4 Partially correct 402 ms 344 KB Output is partially correct
5 Partially correct 877 ms 788 KB Output is partially correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 30 ms 344 KB Output is correct
8 Partially correct 156 ms 456 KB Output is partially correct
9 Partially correct 313 ms 440 KB Output is partially correct
10 Partially correct 906 ms 956 KB Output is partially correct
11 Partially correct 844 ms 1016 KB Output is partially correct
12 Partially correct 860 ms 900 KB Output is partially correct
13 Partially correct 885 ms 964 KB Output is partially correct
14 Correct 7 ms 344 KB Output is correct
15 Correct 12 ms 344 KB Output is correct
16 Incorrect 6 ms 344 KB Incorrect
17 Halted 0 ms 0 KB -