답안 #1065130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1065130 2024-08-19T00:03:12 Z vjudge1 가장 긴 여행 (IOI23_longesttrip) C++17
40 / 100
905 ms 1480 KB
#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[256];
bitset<256>vis;
void dfs(int n){
    if(vis[n])return;
    vis[n]=1;
    for(auto i:adj[n])
        dfs(i);
}
vector<int>path;
void dfs2(int n){
    path.push_back(n);
    vis[n]=1;
    for(auto i:adj[n])
        if(!vis[i])
            return dfs2(i);
}
mt19937 rng(1272842334);
vector<int> longest_trip(int N, int D){
    for(int i=0;i<N;i++)
        adj[i].clear();
    for(int i=1;i<N;i++) for(int j=i;j--;)
        if(are_connected({i},{j}))
            adj[i].push_back(j),
            adj[j].push_back(i);
    vis.reset();
    path.clear();
    int nod=rng()%N;
    dfs2(nod);
    if(path.size()==N)
        return path;
    for(auto x:adj[nod])
        if(!vis[x]) {
            vector<int>v2;
            vis[x]=1;
            for(int i=0;i<N;i++)
                if(!vis[i])v2.push_back(i);
            v2.push_back(x);
            for(auto i:path)
                v2.push_back(i);
            return v2;
        }
    vector<int>b;
    for(int i=0;i<N;i++)
        if(!vis[i])
            b.push_back(i);
    return path.size()>b.size()?path:b;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:32:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     if(path.size()==N)
      |        ~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 206 ms 1416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 148 ms 344 KB Output is correct
4 Correct 404 ms 848 KB Output is correct
5 Correct 829 ms 1124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Correct 133 ms 344 KB Output is correct
4 Correct 393 ms 468 KB Output is correct
5 Correct 870 ms 860 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 19 ms 344 KB Output is correct
8 Correct 150 ms 344 KB Output is correct
9 Correct 322 ms 592 KB Output is correct
10 Correct 842 ms 1008 KB Output is correct
11 Correct 869 ms 1000 KB Output is correct
12 Correct 850 ms 872 KB Output is correct
13 Correct 844 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 151 ms 344 KB Output is correct
4 Correct 407 ms 724 KB Output is correct
5 Correct 848 ms 1032 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 23 ms 344 KB Output is correct
8 Correct 160 ms 344 KB Output is correct
9 Correct 308 ms 472 KB Output is correct
10 Correct 795 ms 1164 KB Output is correct
11 Correct 840 ms 1372 KB Output is correct
12 Correct 883 ms 1008 KB Output is correct
13 Correct 837 ms 1124 KB Output is correct
14 Correct 5 ms 344 KB Output is correct
15 Correct 9 ms 344 KB Output is correct
16 Correct 44 ms 344 KB Output is correct
17 Correct 106 ms 600 KB Output is correct
18 Correct 145 ms 460 KB Output is correct
19 Correct 328 ms 488 KB Output is correct
20 Correct 309 ms 592 KB Output is correct
21 Correct 818 ms 856 KB Output is correct
22 Correct 838 ms 1200 KB Output is correct
23 Correct 776 ms 892 KB Output is correct
24 Correct 839 ms 1004 KB Output is correct
25 Correct 7 ms 344 KB Output is correct
26 Correct 14 ms 344 KB Output is correct
27 Correct 22 ms 344 KB Output is correct
28 Correct 24 ms 344 KB Output is correct
29 Correct 26 ms 344 KB Output is correct
30 Correct 182 ms 344 KB Output is correct
31 Correct 207 ms 344 KB Output is correct
32 Correct 191 ms 456 KB Output is correct
33 Correct 315 ms 600 KB Output is correct
34 Correct 293 ms 344 KB Output is correct
35 Correct 292 ms 732 KB Output is correct
36 Correct 891 ms 744 KB Output is correct
37 Correct 850 ms 1256 KB Output is correct
38 Correct 844 ms 924 KB Output is correct
39 Correct 895 ms 1480 KB Output is correct
40 Correct 881 ms 1060 KB Output is correct
41 Correct 905 ms 1036 KB Output is correct
42 Correct 831 ms 784 KB Output is correct
43 Correct 826 ms 1080 KB Output is correct
44 Correct 816 ms 796 KB Output is correct
45 Correct 9 ms 344 KB Output is correct
46 Correct 8 ms 344 KB Output is correct
47 Correct 20 ms 344 KB Output is correct
48 Correct 23 ms 340 KB Output is correct
49 Correct 25 ms 344 KB Output is correct
50 Correct 216 ms 344 KB Output is correct
51 Correct 175 ms 344 KB Output is correct
52 Correct 189 ms 600 KB Output is correct
53 Correct 321 ms 344 KB Output is correct
54 Correct 309 ms 460 KB Output is correct
55 Correct 287 ms 704 KB Output is correct
56 Correct 875 ms 1184 KB Output is correct
57 Correct 891 ms 1144 KB Output is correct
58 Correct 816 ms 948 KB Output is correct
59 Correct 876 ms 952 KB Output is correct
60 Correct 786 ms 948 KB Output is correct
61 Correct 823 ms 1040 KB Output is correct
62 Correct 750 ms 1316 KB Output is correct
63 Correct 798 ms 956 KB Output is correct
64 Correct 844 ms 956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Partially correct 160 ms 600 KB Output is partially correct
4 Partially correct 404 ms 488 KB Output is partially correct
5 Partially correct 812 ms 1160 KB Output is partially correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 32 ms 344 KB Output is correct
8 Partially correct 153 ms 460 KB Output is partially correct
9 Partially correct 305 ms 600 KB Output is partially correct
10 Partially correct 775 ms 1132 KB Output is partially correct
11 Partially correct 863 ms 884 KB Output is partially correct
12 Partially correct 798 ms 768 KB Output is partially correct
13 Partially correct 849 ms 928 KB Output is partially correct
14 Correct 10 ms 340 KB Output is correct
15 Correct 15 ms 344 KB Output is correct
16 Incorrect 1 ms 344 KB Incorrect
17 Halted 0 ms 0 KB -