제출 #841552

#제출 시각아이디문제언어결과실행 시간메모리
841552StavabLongest Trip (IOI23_longesttrip)C++17
0 / 100
27 ms348 KiB
#include "longesttrip.h"
#include <algorithm>

std::vector<std::vector<int>> graph;
std::vector<int> solution, visited, temp;

void dfs(int n, std::vector<int> &v)
{
    if(visited[n]) return;

    visited[n] = 1;
    v.push_back(n);
    for(int i = 0; i < graph[n].size(); i++)
        dfs(graph[n][i], v);

    if(temp.size() > solution.size())
        solution = temp;

    temp.pop_back();
}

std::vector<int> longest_trip(int N, int D)
{
    graph.assign(N, std::vector<int>());
    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            if(are_connected({i}, {j}));
            {
                graph[i].push_back(j);
                graph[j].push_back(i);
            }
        }
    }

    visited.assign(N, 0);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
            visited[j] = 0;
        dfs(i, temp);
    }

    return solution;
}

컴파일 시 표준 에러 (stderr) 메시지

longesttrip.cpp: In function 'void dfs(int, std::vector<int>&)':
longesttrip.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i = 0; i < graph[n].size(); i++)
      |                    ~~^~~~~~~~~~~~~~~~~
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:29:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   29 |             if(are_connected({i}, {j}));
      |             ^~
longesttrip.cpp:30:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   30 |             {
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...