Submission #843896

# Submission time Handle Problem Language Result Execution time Memory
843896 2023-09-04T16:42:31 Z LucaIlie Longest Trip (IOI23_longesttrip) C++17
30 / 100
773 ms 2284 KB
#include "longesttrip.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 256;
bool vis[MAX_N];
vector<int> edges[MAX_N];
vector<int> best, ans;

int getEdge( int u ) {
    vector<int> x;
    for ( int v: edges[u] ) {
        if ( !vis[v] )
            x.push_back( v );
    }

    if ( x.size() == 0 )
        return -1;
    return x[rand() % x.size()];
}

vector<int> longest_trip( int n, int d ) {
    for ( int u = 0; u < n; u++ ) {
        edges[u].clear();
        vis[u] = false;
    }

    for ( int u = 0; u < n; u++ ) {
        for ( int v = u + 1; v < n; v++ ) {
            int x = are_connected( { u }, { v } );
            if ( x ) {
                edges[u].push_back( v );
                edges[v].push_back( u );
            }
        }
    }

    best.clear();
    for ( int s = 0; s < n; s++ ) {
        int u = s;
        ans.clear();
        ans.push_back( u );
        vis[u] = true;

        int v = getEdge( u );
        while ( v >= 0 ) {
            ans.push_back( v );
            vis[v] = true;

            u = v;
            v = getEdge( u );
        }
        if ( ans.size() > best.size() )
            best = ans;
    }

    return best;
}
# 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 8 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 124 ms 600 KB Output is correct
4 Correct 340 ms 1148 KB Output is correct
5 Correct 689 ms 1636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 344 KB Output is correct
2 Correct 18 ms 344 KB Output is correct
3 Correct 124 ms 600 KB Output is correct
4 Correct 358 ms 868 KB Output is correct
5 Correct 752 ms 2140 KB Output is correct
6 Incorrect 0 ms 344 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Output is correct
2 Correct 22 ms 344 KB Output is correct
3 Correct 121 ms 856 KB Output is correct
4 Correct 352 ms 1368 KB Output is correct
5 Correct 689 ms 1252 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 24 ms 344 KB Output is correct
8 Correct 127 ms 704 KB Output is correct
9 Correct 277 ms 1112 KB Output is correct
10 Correct 746 ms 1128 KB Output is correct
11 Correct 720 ms 1132 KB Output is correct
12 Correct 760 ms 1392 KB Output is correct
13 Correct 704 ms 1660 KB Output is correct
14 Correct 6 ms 344 KB Output is correct
15 Correct 9 ms 344 KB Output is correct
16 Correct 45 ms 344 KB Output is correct
17 Correct 70 ms 600 KB Output is correct
18 Correct 127 ms 1116 KB Output is correct
19 Correct 270 ms 1140 KB Output is correct
20 Correct 260 ms 1112 KB Output is correct
21 Correct 686 ms 1348 KB Output is correct
22 Correct 721 ms 2284 KB Output is correct
23 Correct 684 ms 1564 KB Output is correct
24 Correct 658 ms 1296 KB Output is correct
25 Correct 9 ms 344 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 22 ms 344 KB Output is correct
28 Correct 23 ms 496 KB Output is correct
29 Correct 21 ms 344 KB Output is correct
30 Correct 158 ms 708 KB Output is correct
31 Correct 175 ms 708 KB Output is correct
32 Correct 157 ms 700 KB Output is correct
33 Correct 249 ms 976 KB Output is correct
34 Correct 248 ms 984 KB Output is correct
35 Correct 256 ms 964 KB Output is correct
36 Correct 725 ms 1348 KB Output is correct
37 Correct 700 ms 1112 KB Output is correct
38 Correct 690 ms 968 KB Output is correct
39 Correct 687 ms 1616 KB Output is correct
40 Correct 678 ms 1296 KB Output is correct
41 Correct 756 ms 1040 KB Output is correct
42 Correct 724 ms 1256 KB Output is correct
43 Correct 731 ms 1932 KB Output is correct
44 Correct 740 ms 1684 KB Output is correct
45 Correct 9 ms 344 KB Output is correct
46 Correct 8 ms 344 KB Output is correct
47 Correct 27 ms 344 KB Output is correct
48 Correct 21 ms 344 KB Output is correct
49 Correct 20 ms 344 KB Output is correct
50 Correct 149 ms 948 KB Output is correct
51 Correct 180 ms 1208 KB Output is correct
52 Correct 173 ms 856 KB Output is correct
53 Correct 238 ms 1200 KB Output is correct
54 Correct 256 ms 868 KB Output is correct
55 Correct 255 ms 724 KB Output is correct
56 Correct 714 ms 1316 KB Output is correct
57 Correct 674 ms 1052 KB Output is correct
58 Correct 684 ms 1268 KB Output is correct
59 Correct 743 ms 1868 KB Output is correct
60 Correct 678 ms 1552 KB Output is correct
61 Correct 679 ms 1204 KB Output is correct
62 Correct 698 ms 1256 KB Output is correct
63 Correct 701 ms 1992 KB Output is correct
64 Correct 773 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 20 ms 344 KB Output is correct
3 Partially correct 109 ms 600 KB Output is partially correct
4 Partially correct 367 ms 848 KB Output is partially correct
5 Partially correct 684 ms 1260 KB Output is partially correct
6 Incorrect 1 ms 544 KB Incorrect
7 Halted 0 ms 0 KB -