Submission #916001

# Submission time Handle Problem Language Result Execution time Memory
916001 2024-01-25T05:51:45 Z chirathnirodha Longest Trip (IOI23_longesttrip) C++17
5 / 100
1000 ms 2128 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];
int n,ans;

vector<int> t,curv;
bool visited[256];
void dfs(int x,int cur){
    if(ans==(n+1)/2)return;
    curv.PB(x);
    visited[x]=true;

    if(ans<cur){
        t=curv;
        ans=cur;
    }

    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){
    n=N;
    if(D==3){
        vector<int> tt;for(int i=0;i<n;i++)tt.PB(i);
        return tt;
    }
    memset(visited,false,sizeof(visited));
    for(int i=0;i<n;i++)v[i].clear();
    ans=0;

    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);}
        }
    }
    for(int i=0;i<n;i++){
        dfs(i,1);
    }
    return t;
}

Compilation message

longesttrip.cpp: In function 'void dfs(int, int)':
longesttrip.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     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 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# 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 Correct 6 ms 344 KB Output is correct
2 Correct 19 ms 344 KB Output is correct
3 Correct 117 ms 1368 KB Output is correct
4 Correct 327 ms 856 KB Output is correct
5 Correct 646 ms 1712 KB Output is correct
6 Correct 7 ms 340 KB Output is correct
7 Correct 19 ms 344 KB Output is correct
8 Correct 115 ms 856 KB Output is correct
9 Correct 251 ms 628 KB Output is correct
10 Correct 671 ms 1812 KB Output is correct
11 Correct 673 ms 1500 KB Output is correct
12 Correct 642 ms 1636 KB Output is correct
13 Correct 692 ms 1620 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 9 ms 344 KB Output is correct
16 Correct 30 ms 600 KB Output is correct
17 Correct 68 ms 600 KB Output is correct
18 Correct 109 ms 700 KB Output is correct
19 Correct 228 ms 1112 KB Output is correct
20 Correct 227 ms 1720 KB Output is correct
21 Correct 665 ms 1296 KB Output is correct
22 Correct 666 ms 2112 KB Output is correct
23 Correct 684 ms 2128 KB Output is correct
24 Correct 706 ms 1268 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 8 ms 344 KB Output is correct
27 Correct 26 ms 344 KB Output is correct
28 Correct 26 ms 344 KB Output is correct
29 Correct 21 ms 344 KB Output is correct
30 Correct 168 ms 448 KB Output is correct
31 Execution timed out 3075 ms 1212 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -