Submission #1037896

#TimeUsernameProblemLanguageResultExecution timeMemory
1037896ZicrusLongest Trip (IOI23_longesttrip)C++17
40 / 100
911 ms1584 KiB
#include <bits/stdc++.h> #include "longesttrip.h" using namespace std; typedef long long ll; vector<vector<ll>> adj; vector<bool> vst; mt19937 mt; vector<int> mxRand() { ll n = adj.size(); ll start = mt() % n; ll cur = start; vector<int> res = {(int)start}; loop: vst[cur] = true; shuffle(adj[cur].begin(), adj[cur].end(), mt); for (auto &e : adj[cur]) { if (!vst[e]) { cur = e; res.push_back(e); goto loop; } } for (auto &e : res) vst[e] = false; return res; } vector<int> longest_trip(int n, int d) { mt = mt19937(time(0)); adj = vector<vector<ll>>(n); vst = vector<bool>(n); for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { if (are_connected({i}, {j})) { adj[i].push_back(j); adj[j].push_back(i); } } } vector<int> res; ll comp = n <= 100 ? 150 : 50; if (n <= 50) comp = 300; for (int i = 0; i < 50; i++) { vector<int> nw = mxRand(); if (nw.size() > res.size()) res = nw; } return res; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:44:8: warning: variable 'comp' set but not used [-Wunused-but-set-variable]
   44 |     ll comp = n <= 100 ? 150 : 50;
      |        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...