답안 #1007069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007069 2024-06-24T11:23:25 Z 3as8 가장 긴 여행 (IOI23_longesttrip) C++17
15 / 100
1000 ms 596 KB
#include "longesttrip.h"

#include<bits/stdc++.h>

#define ll long long
using namespace std;

bool con[300][300];
bool vis[300];
bool bkVis[300];

ll n;
ll l = 0;
void dfs(ll startIndex, vector<int>& curr) {


    vis[startIndex] = true;
    curr.push_back(startIndex);

    bool in = false;
    for(int i = 0; i < n; i++) {
        if(con[startIndex][i] && !vis[i]) {
            dfs(i, curr);
            in = true;
        }
    }

    if(!in) l = startIndex;
}


std::vector<int> longest_trip(int N, int D) {

    n = N;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {

            con[i][j] = con[j][i] = are_connected({i}, {j});
        }
    }

    ll mx = LLONG_MIN;
    vector<int> ans;

   // for(int i = 0; i < n; i++) vis[i] = false;


    for(int i = 0; i < n; i++) {

        for(int i = 0; i < n; i++) vis[i] = false;


        vector<int> curr;
        l = i;
        dfs(i, curr);

        for(int i = 0; i < n; i++) vis[i] = false;

        vector<int> curr2;

        dfs(l, curr2);

        if(curr2.size() > ans.size()) {
            ans = curr2;
        }

        if(curr.size() > ans.size()) {
            ans = curr;
        }
    }

    return ans;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:42:8: warning: unused variable 'mx' [-Wunused-variable]
   42 |     ll mx = LLONG_MIN;
      |        ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 232 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 28 ms 344 KB Output is correct
3 Correct 139 ms 344 KB Output is correct
4 Correct 453 ms 592 KB Output is correct
5 Correct 880 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 596 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 125 ms 344 KB Output is correct
4 Correct 410 ms 596 KB Output is correct
5 Correct 984 ms 492 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 20 ms 344 KB Output is correct
8 Correct 148 ms 344 KB Output is correct
9 Correct 325 ms 444 KB Output is correct
10 Correct 913 ms 488 KB Output is correct
11 Correct 983 ms 488 KB Output is correct
12 Correct 971 ms 492 KB Output is correct
13 Correct 946 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 25 ms 344 KB Output is correct
3 Correct 183 ms 344 KB Output is correct
4 Correct 429 ms 452 KB Output is correct
5 Correct 967 ms 488 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 22 ms 344 KB Output is correct
8 Correct 151 ms 344 KB Output is correct
9 Correct 361 ms 448 KB Output is correct
10 Correct 937 ms 488 KB Output is correct
11 Execution timed out 1004 ms 492 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 31 ms 344 KB Output is correct
3 Partially correct 157 ms 344 KB Output is partially correct
4 Partially correct 410 ms 592 KB Output is partially correct
5 Partially correct 980 ms 488 KB Output is partially correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 19 ms 344 KB Output is correct
8 Partially correct 171 ms 344 KB Output is partially correct
9 Partially correct 305 ms 596 KB Output is partially correct
10 Partially correct 968 ms 492 KB Output is partially correct
11 Partially correct 978 ms 492 KB Output is partially correct
12 Partially correct 912 ms 492 KB Output is partially correct
13 Partially correct 928 ms 488 KB Output is partially correct
14 Correct 7 ms 344 KB Output is correct
15 Correct 9 ms 344 KB Output is correct
16 Incorrect 1 ms 344 KB Incorrect
17 Halted 0 ms 0 KB -