Submission #841488

#TimeUsernameProblemLanguageResultExecution timeMemory
841488flashmt가장 긴 여행 (IOI23_longesttrip)C++17
0 / 100
2 ms464 KiB
#include <bits/stdc++.h> #include "longesttrip.h" using namespace std; vector<int> longest_trip(int n, int d) { vector<vector<int>> a(n, vector<int>(n)); for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) a[i][j] = a[j][i] = are_connected({i}, {j}); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) for (int k = 0; k < n; k++) if (a[i][j] && a[j][k]) { deque<int> q; q.push_back(i); q.push_back(j); q.push_back(k); for (int p = 0; p < n; p++) if (p != i && p != j && p != k) { if (a[p][q.back()]) q.push_back(p); else { assert(a[p][q.front()]); q.push_front(p); } } vector<int> ans; while (!empty(q)) { ans.push_back(q.front()); q.pop_front(); } assert(size(ans) == n); return ans; } for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if (a[i][j]) { return {i, j}; } assert(0); return {}; }

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from longesttrip.cpp:1:
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:38:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |           assert(size(ans) == n);
      |                  ~~~~~~~~~~^~~~
#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...