답안 #1076228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076228 2024-08-26T12:00:09 Z MarwenElarbi 가장 긴 여행 (IOI23_longesttrip) C++17
30 / 100
945 ms 1548 KB
#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
const int nax = 2e5+5;
const int MOD = 1e9+7;
vector<int> adj[256];
bool vis[256];
set<int> components[256];
vector<int> cur;
void dfs(int x){
    cur.pb(x);
    vis[x]=true;
    for(auto u:adj[x]){
        if(vis[u]) continue;
        dfs(u);
        return;
    }
}
std::vector<int> longest_trip(int N, int D)
{
    for (int i = 0; i < N; ++i)
    {
        adj[i].clear();
    }
    for (int i = 0; i < N; ++i)
    {
        for (int j = i+1; j < N; ++j)
        {
            if(are_connected({i},{j})){
                adj[i].pb(j);
                adj[j].pb(i);
            }
        }
    }
    int t=10;
    vector<int> ans;
    while(t--){
        for (int i = 0; i < N; ++i)
        {
            vis[i]=0;
            random_shuffle(adj[i].begin(),adj[i].end()); 
        }
        for (int i = 0; i < N; ++i)
        {
            if(vis[i]) continue;
            cur.clear();
            dfs(i);
            if(ans.size()<cur.size()) ans=cur;
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 231 ms 1356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 19 ms 340 KB Output is correct
3 Correct 172 ms 344 KB Output is correct
4 Correct 446 ms 344 KB Output is correct
5 Correct 931 ms 900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 28 ms 344 KB Output is correct
3 Correct 124 ms 612 KB Output is correct
4 Correct 401 ms 500 KB Output is correct
5 Correct 795 ms 876 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 344 KB Output is correct
2 Correct 30 ms 344 KB Output is correct
3 Correct 153 ms 344 KB Output is correct
4 Correct 423 ms 852 KB Output is correct
5 Correct 860 ms 1156 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 23 ms 344 KB Output is correct
8 Correct 166 ms 344 KB Output is correct
9 Correct 354 ms 852 KB Output is correct
10 Correct 878 ms 808 KB Output is correct
11 Correct 883 ms 828 KB Output is correct
12 Correct 886 ms 1000 KB Output is correct
13 Correct 865 ms 720 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 15 ms 344 KB Output is correct
16 Correct 38 ms 344 KB Output is correct
17 Correct 94 ms 344 KB Output is correct
18 Correct 166 ms 460 KB Output is correct
19 Correct 330 ms 724 KB Output is correct
20 Correct 344 ms 600 KB Output is correct
21 Correct 824 ms 904 KB Output is correct
22 Correct 863 ms 1332 KB Output is correct
23 Correct 945 ms 876 KB Output is correct
24 Correct 870 ms 1144 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 29 ms 344 KB Output is correct
28 Correct 20 ms 344 KB Output is correct
29 Correct 19 ms 344 KB Output is correct
30 Correct 220 ms 600 KB Output is correct
31 Correct 179 ms 460 KB Output is correct
32 Correct 213 ms 600 KB Output is correct
33 Correct 338 ms 848 KB Output is correct
34 Correct 314 ms 856 KB Output is correct
35 Correct 316 ms 712 KB Output is correct
36 Correct 829 ms 796 KB Output is correct
37 Correct 857 ms 1548 KB Output is correct
38 Correct 852 ms 1080 KB Output is correct
39 Correct 769 ms 948 KB Output is correct
40 Correct 833 ms 1296 KB Output is correct
41 Correct 888 ms 1000 KB Output is correct
42 Correct 890 ms 992 KB Output is correct
43 Correct 853 ms 1232 KB Output is correct
44 Correct 849 ms 1428 KB Output is correct
45 Correct 10 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 26 ms 344 KB Output is correct
49 Correct 23 ms 344 KB Output is correct
50 Correct 209 ms 344 KB Output is correct
51 Correct 182 ms 344 KB Output is correct
52 Correct 184 ms 464 KB Output is correct
53 Correct 326 ms 856 KB Output is correct
54 Correct 324 ms 600 KB Output is correct
55 Correct 336 ms 732 KB Output is correct
56 Correct 883 ms 944 KB Output is correct
57 Correct 877 ms 1048 KB Output is correct
58 Correct 884 ms 1052 KB Output is correct
59 Correct 871 ms 1340 KB Output is correct
60 Correct 867 ms 1196 KB Output is correct
61 Correct 839 ms 1300 KB Output is correct
62 Correct 857 ms 996 KB Output is correct
63 Correct 867 ms 1444 KB Output is correct
64 Correct 857 ms 1188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 21 ms 344 KB Output is correct
3 Partially correct 159 ms 600 KB Output is partially correct
4 Partially correct 456 ms 716 KB Output is partially correct
5 Partially correct 885 ms 1372 KB Output is partially correct
6 Incorrect 1 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -