답안 #1076227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076227 2024-08-26T11:59:50 Z MarwenElarbi 가장 긴 여행 (IOI23_longesttrip) C++17
0 / 100
1000 ms 1364 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=100;
    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 1 ms 344 KB Output is correct
2 Correct 264 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 344 KB Output is correct
2 Correct 41 ms 344 KB Output is correct
3 Correct 232 ms 344 KB Output is correct
4 Correct 538 ms 344 KB Output is correct
5 Execution timed out 1180 ms 1000 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 34 ms 344 KB Output is correct
3 Correct 232 ms 472 KB Output is correct
4 Correct 565 ms 1364 KB Output is correct
5 Execution timed out 1135 ms 960 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 344 KB Output is correct
2 Correct 35 ms 344 KB Output is correct
3 Correct 218 ms 472 KB Output is correct
4 Correct 659 ms 744 KB Output is correct
5 Execution timed out 1100 ms 976 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 55 ms 344 KB Output is correct
3 Partially correct 203 ms 344 KB Output is partially correct
4 Partially correct 595 ms 600 KB Output is partially correct
5 Execution timed out 1081 ms 1000 KB Time limit exceeded
6 Halted 0 ms 0 KB -