Submission #915971

# Submission time Handle Problem Language Result Execution time Memory
915971 2024-01-25T04:40:04 Z chirathnirodha Longest Trip (IOI23_longesttrip) C++17
0 / 100
1000 ms 744 KB
#include "longesttrip.h"
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define P push
#define I insert 
#define F first
#define S second
typedef long long ll;

vector<int> v[256];
bool grid[256][256];
int ans=0;
vector<int> t;
vector<int> curv;
bool visited[256];
void dfs(int x,int cur){
    curv.PB(x);
    if(ans<cur){
        t=curv;
        ans=cur;
    }
    visited[x]=true;
    for(int i=0;i<v[x].size();i++){
        int y=v[x][i];
        if(visited[y])continue;
        dfs(y,cur+1);
    }
    visited[x]=false;
    curv.pop_back();
}
vector<int> longest_trip(int n, int D){
    memset(grid,false,sizeof(grid));
    memset(visited,false,sizeof(visited));
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(are_connected({i},{j})){v[i].PB(j);v[j].PB(i); grid[i][j]=grid[j][i]=true;}
        }
    }
    for(int i=0;i<n;i++){
        dfs(i,1);
    }
    return t;
}

Compilation message

longesttrip.cpp: In function 'void dfs(int, int)':
longesttrip.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0;i<v[x].size();i++){
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3100 ms 744 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3015 ms 740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3010 ms 492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3098 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -