Submission #1080934

#TimeUsernameProblemLanguageResultExecution timeMemory
1080934asdasdqwerLongest Trip (IOI23_longesttrip)C++17
40 / 100
929 ms1324 KiB
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; std::vector<int> longest_trip(int N, int D) { vector<vector<int>> g(N); if (D == 3) { vector<int> v; for (int i=0;i<N;i++) { v.push_back(i); } return v; } for (int i=0;i<N;i++) { for (int j=i+1;j<N;j++) { if (are_connected({i}, {j})) { g[i].push_back(j); g[j].push_back(i); } } } int tries = 17; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); for (int i=0;i<N;i++) { shuffle(g[i].begin(), g[i].end(), rng); } vector<int> lng; for (int i=0;i<N;i++) { vector<int> tmp; vector<bool> vis(N, false); function<void(int)> dfs=[&](int node) { vis[node] = true; tmp.push_back(node); for (int x:g[node]) { if (!vis[x]) { dfs(x); break; } } }; dfs(i); if (lng.size() < tmp.size()) { lng = tmp; } if ((D == 2 && lng.size() == N) || (D == 1 && lng.size() >= (N/2+1))) return lng; } return lng; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:53:35: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |         if ((D == 2 && lng.size() == N) || (D == 1 && lng.size() >= (N/2+1))) return lng;
      |                        ~~~~~~~~~~~^~~~
longesttrip.cpp:53:66: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |         if ((D == 2 && lng.size() == N) || (D == 1 && lng.size() >= (N/2+1))) return lng;
      |                                                       ~~~~~~~~~~~^~~~~~~~~~
longesttrip.cpp:25:9: warning: unused variable 'tries' [-Wunused-variable]
   25 |     int tries = 17;
      |         ^~~~~
#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...