Submission #1079562

# Submission time Handle Problem Language Result Execution time Memory
1079562 2024-08-28T17:07:28 Z c2zi6 Longest Trip (IOI23_longesttrip) C++17
25 / 100
906 ms 1668 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "longesttrip.h"

int n;
VVI gp;
VVI edges;

VI longest_trip(int N, int D) {
    n = N;
    gp = VVI(n);
    edges = VVI(n, VI(n));
    replr(i, 0, n-1) {
        replr(j, i+1, n-1) {
            if (are_connected({i}, {j})) {
                gp[i].pb(j);
                gp[j].pb(i);
                edges[i][j] = edges[j][i] = true;
            }
        }
    }
    VI path1;
    VI path2;
    path1.pb(0);
    path2.pb(1);
    replr(u, 2, n-1) {
        if (edges[path1.back()][u]) path1.pb(u);
        else if (edges[path2.back()][u]) path2.pb(u);
        else {
            while (path2.size()) {
                path1.pb(path2.back());
                path2.pop_back();
            }
            path2.pb(u);
        }
    }
    if (path1.size() > path2.size()) return path1;
    return path2;
    for (int x : path1) cout << x << " "; cout << endl;
    for (int x : path2) cout << x << " "; cout << endl;
    return {0};
}







Compilation message

longesttrip.cpp: In function 'VI longest_trip(int, int)':
longesttrip.cpp:68:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   68 |     for (int x : path1) cout << x << " "; cout << endl;
      |     ^~~
longesttrip.cpp:68:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   68 |     for (int x : path1) cout << x << " "; cout << endl;
      |                                           ^~~~
longesttrip.cpp:69:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   69 |     for (int x : path2) cout << x << " "; cout << endl;
      |     ^~~
longesttrip.cpp:69:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   69 |     for (int x : path2) cout << x << " "; cout << endl;
      |                                           ^~~~
# 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 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# 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 7 ms 344 KB Output is correct
2 Correct 27 ms 344 KB Output is correct
3 Correct 136 ms 464 KB Output is correct
4 Correct 305 ms 784 KB Output is correct
5 Correct 771 ms 1108 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 25 ms 344 KB Output is correct
8 Correct 146 ms 344 KB Output is correct
9 Correct 327 ms 600 KB Output is correct
10 Correct 847 ms 1244 KB Output is correct
11 Correct 861 ms 1244 KB Output is correct
12 Correct 875 ms 1244 KB Output is correct
13 Correct 830 ms 1348 KB Output is correct
14 Correct 7 ms 344 KB Output is correct
15 Correct 10 ms 344 KB Output is correct
16 Correct 52 ms 344 KB Output is correct
17 Correct 91 ms 344 KB Output is correct
18 Correct 173 ms 456 KB Output is correct
19 Correct 311 ms 1048 KB Output is correct
20 Correct 304 ms 548 KB Output is correct
21 Correct 832 ms 1668 KB Output is correct
22 Correct 809 ms 1028 KB Output is correct
23 Correct 875 ms 1276 KB Output is correct
24 Correct 833 ms 1252 KB Output is correct
25 Correct 9 ms 340 KB Output is correct
26 Correct 9 ms 344 KB Output is correct
27 Correct 22 ms 344 KB Output is correct
28 Correct 17 ms 344 KB Output is correct
29 Correct 25 ms 344 KB Output is correct
30 Correct 209 ms 460 KB Output is correct
31 Correct 184 ms 456 KB Output is correct
32 Correct 207 ms 344 KB Output is correct
33 Correct 320 ms 668 KB Output is correct
34 Correct 325 ms 668 KB Output is correct
35 Correct 318 ms 1024 KB Output is correct
36 Correct 843 ms 1236 KB Output is correct
37 Correct 793 ms 1456 KB Output is correct
38 Correct 873 ms 1124 KB Output is correct
39 Correct 853 ms 1228 KB Output is correct
40 Correct 845 ms 1384 KB Output is correct
41 Correct 846 ms 1104 KB Output is correct
42 Correct 865 ms 1244 KB Output is correct
43 Correct 906 ms 1364 KB Output is correct
44 Correct 871 ms 1384 KB Output is correct
45 Correct 8 ms 344 KB Output is correct
46 Correct 7 ms 344 KB Output is correct
47 Correct 28 ms 344 KB Output is correct
48 Correct 17 ms 344 KB Output is correct
49 Correct 17 ms 344 KB Output is correct
50 Correct 206 ms 612 KB Output is correct
51 Correct 202 ms 592 KB Output is correct
52 Correct 214 ms 716 KB Output is correct
53 Correct 347 ms 728 KB Output is correct
54 Correct 335 ms 752 KB Output is correct
55 Correct 333 ms 780 KB Output is correct
56 Correct 877 ms 1368 KB Output is correct
57 Correct 824 ms 1228 KB Output is correct
58 Correct 792 ms 1120 KB Output is correct
59 Correct 807 ms 1108 KB Output is correct
60 Correct 760 ms 1304 KB Output is correct
61 Correct 823 ms 1020 KB Output is correct
62 Correct 835 ms 1524 KB Output is correct
63 Correct 811 ms 1536 KB Output is correct
64 Correct 795 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -