답안 #1007048

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

#include<bits/stdc++.h>

#define ll long long
using namespace std;

bool con[300][300];
bool vis[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});
        }
    }

    vector<ll> ans;
    ll mx = LLONG_MIN;
    for(int j = 0; j < n; j++) vis[j] = false;
    vector<int> curr;

    dfs(0, curr);

    for(int j = 0; j < n; j++) vis[j] = false;
    vector<int> curr2;

    dfs(l, curr2);

    return curr2;
}

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 0 ms 344 KB Output is correct
2 Correct 218 ms 508 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 Correct 162 ms 344 KB Output is correct
4 Correct 449 ms 592 KB Output is correct
5 Correct 842 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 23 ms 344 KB Output is correct
3 Correct 143 ms 344 KB Output is correct
4 Correct 407 ms 468 KB Output is correct
5 Correct 811 ms 492 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 23 ms 344 KB Output is correct
8 Correct 140 ms 344 KB Output is correct
9 Correct 303 ms 344 KB Output is correct
10 Correct 844 ms 504 KB Output is correct
11 Correct 825 ms 488 KB Output is correct
12 Correct 761 ms 488 KB Output is correct
13 Correct 771 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 19 ms 344 KB Output is correct
3 Correct 139 ms 344 KB Output is correct
4 Correct 407 ms 344 KB Output is correct
5 Correct 797 ms 492 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 19 ms 344 KB Output is correct
8 Correct 140 ms 344 KB Output is correct
9 Correct 261 ms 444 KB Output is correct
10 Correct 768 ms 588 KB Output is correct
11 Correct 794 ms 492 KB Output is correct
12 Correct 817 ms 488 KB Output is correct
13 Correct 865 ms 488 KB Output is correct
14 Correct 8 ms 344 KB Output is correct
15 Incorrect 2 ms 344 KB Incorrect
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 31 ms 344 KB Output is correct
3 Partially correct 158 ms 344 KB Output is partially correct
4 Partially correct 366 ms 592 KB Output is partially correct
5 Partially correct 786 ms 488 KB Output is partially correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 24 ms 344 KB Output is correct
8 Partially correct 131 ms 344 KB Output is partially correct
9 Partially correct 309 ms 344 KB Output is partially correct
10 Partially correct 814 ms 492 KB Output is partially correct
11 Partially correct 787 ms 496 KB Output is partially correct
12 Partially correct 790 ms 492 KB Output is partially correct
13 Partially correct 777 ms 488 KB Output is partially correct
14 Incorrect 0 ms 344 KB Incorrect
15 Halted 0 ms 0 KB -