Submission #1065232

# Submission time Handle Problem Language Result Execution time Memory
1065232 2024-08-19T03:58:08 Z LittleOrange Longest Trip (IOI23_longesttrip) C++17
40 / 100
964 ms 848 KB
#include "longesttrip.h"

#include <vector>
#include<bits/stdc++.h>
using namespace std;
using ll = int;

std::vector<int> longest_trip(int N, int D)
{
    mt19937_64 mt(random_device{}());
    ll t0 = time(0);
    ll n = N;
    if (D==3){
        vector<ll> r(n);
        iota(r.begin(),r.end(),0);
        return r;
    }
    vector<vector<ll>> a(n,vector<ll>(n,0));
    for(ll i = 0;i<n;i++){
        for(ll j = i+1;j<n;j++){
            a[i][j] = a[j][i] = are_connected({i},{j});
        }
    }
    vector<ll> ret;
    vector<ll> ord(n);
    iota(ord.begin(),ord.end(),0);
    auto it = ord.begin();
    vector<ll> cur;
    cur.reserve(n);
    ll cnt = 5000;
    while(cnt--){
        shuffle(ord.begin(),ord.end(),mt);
        cur.push_back(ord[0]);
        for(ll i : ord){
            if (a[cur.back()][i]) cur.push_back(i);
        }
        if(cur.size()>ret.size()) ret = cur;
        cur.clear();
    }
    return ret;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:11:8: warning: unused variable 't0' [-Wunused-variable]
   11 |     ll t0 = time(0);
      |        ^~
longesttrip.cpp:27:10: warning: variable 'it' set but not used [-Wunused-but-set-variable]
   27 |     auto it = ord.begin();
      |          ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 217 ms 692 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 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 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 344 KB Output is correct
2 Correct 81 ms 344 KB Output is correct
3 Correct 201 ms 344 KB Output is correct
4 Correct 438 ms 504 KB Output is correct
5 Correct 891 ms 600 KB Output is correct
6 Correct 79 ms 344 KB Output is correct
7 Correct 94 ms 344 KB Output is correct
8 Correct 204 ms 344 KB Output is correct
9 Correct 379 ms 344 KB Output is correct
10 Correct 839 ms 688 KB Output is correct
11 Correct 864 ms 688 KB Output is correct
12 Correct 894 ms 680 KB Output is correct
13 Correct 888 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 344 KB Output is correct
2 Correct 71 ms 344 KB Output is correct
3 Correct 192 ms 344 KB Output is correct
4 Correct 439 ms 484 KB Output is correct
5 Correct 895 ms 600 KB Output is correct
6 Correct 75 ms 344 KB Output is correct
7 Correct 85 ms 344 KB Output is correct
8 Correct 197 ms 344 KB Output is correct
9 Correct 349 ms 344 KB Output is correct
10 Correct 910 ms 688 KB Output is correct
11 Correct 832 ms 600 KB Output is correct
12 Correct 887 ms 684 KB Output is correct
13 Correct 869 ms 692 KB Output is correct
14 Correct 84 ms 344 KB Output is correct
15 Correct 80 ms 344 KB Output is correct
16 Correct 126 ms 344 KB Output is correct
17 Correct 146 ms 344 KB Output is correct
18 Correct 211 ms 344 KB Output is correct
19 Correct 369 ms 456 KB Output is correct
20 Correct 385 ms 476 KB Output is correct
21 Correct 838 ms 696 KB Output is correct
22 Correct 899 ms 848 KB Output is correct
23 Correct 863 ms 692 KB Output is correct
24 Correct 877 ms 692 KB Output is correct
25 Correct 85 ms 344 KB Output is correct
26 Correct 74 ms 344 KB Output is correct
27 Correct 91 ms 344 KB Output is correct
28 Correct 80 ms 344 KB Output is correct
29 Correct 75 ms 344 KB Output is correct
30 Correct 246 ms 344 KB Output is correct
31 Correct 233 ms 344 KB Output is correct
32 Correct 274 ms 344 KB Output is correct
33 Correct 361 ms 344 KB Output is correct
34 Correct 370 ms 344 KB Output is correct
35 Correct 347 ms 344 KB Output is correct
36 Correct 903 ms 600 KB Output is correct
37 Correct 862 ms 600 KB Output is correct
38 Correct 906 ms 600 KB Output is correct
39 Correct 913 ms 600 KB Output is correct
40 Correct 954 ms 600 KB Output is correct
41 Correct 907 ms 600 KB Output is correct
42 Correct 964 ms 600 KB Output is correct
43 Correct 924 ms 596 KB Output is correct
44 Correct 953 ms 600 KB Output is correct
45 Correct 86 ms 344 KB Output is correct
46 Correct 88 ms 344 KB Output is correct
47 Correct 87 ms 344 KB Output is correct
48 Correct 81 ms 344 KB Output is correct
49 Correct 88 ms 344 KB Output is correct
50 Correct 239 ms 344 KB Output is correct
51 Correct 255 ms 344 KB Output is correct
52 Correct 275 ms 344 KB Output is correct
53 Correct 346 ms 344 KB Output is correct
54 Correct 356 ms 344 KB Output is correct
55 Correct 342 ms 344 KB Output is correct
56 Correct 905 ms 688 KB Output is correct
57 Correct 869 ms 684 KB Output is correct
58 Correct 866 ms 600 KB Output is correct
59 Correct 923 ms 600 KB Output is correct
60 Correct 894 ms 684 KB Output is correct
61 Correct 959 ms 684 KB Output is correct
62 Correct 861 ms 688 KB Output is correct
63 Correct 869 ms 688 KB Output is correct
64 Correct 884 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 344 KB Output is correct
2 Correct 68 ms 344 KB Output is correct
3 Partially correct 200 ms 344 KB Output is partially correct
4 Partially correct 414 ms 480 KB Output is partially correct
5 Partially correct 847 ms 600 KB Output is partially correct
6 Correct 72 ms 344 KB Output is correct
7 Correct 76 ms 344 KB Output is correct
8 Partially correct 194 ms 344 KB Output is partially correct
9 Partially correct 355 ms 344 KB Output is partially correct
10 Partially correct 890 ms 688 KB Output is partially correct
11 Partially correct 841 ms 684 KB Output is partially correct
12 Partially correct 865 ms 600 KB Output is partially correct
13 Partially correct 844 ms 600 KB Output is partially correct
14 Correct 75 ms 340 KB Output is correct
15 Correct 78 ms 344 KB Output is correct
16 Incorrect 14 ms 344 KB Incorrect
17 Halted 0 ms 0 KB -