제출 #878561

#제출 시각아이디문제언어결과실행 시간메모리
878561thinknoexit가장 긴 여행 (IOI23_longesttrip)C++17
5 / 100
771 ms596 KiB
#include <bits/stdc++.h> #include "longesttrip.h" using namespace std; using ll = long long; int n, d; bool adj[256][256]; vector<int> longest_trip(int N, int D) { n = N; d = D; memset(adj, 0, sizeof adj); for (int i = 0;i < n;i++) { for (int j = i + 1;j < n;j++) { adj[i][j] = adj[j][i] = are_connected({ i }, { j }); } } queue<int> q; deque<int> ans; ans.push_back(0); for (int i = 1;i < n;i++) { if (adj[0][i]) { ans.push_back(i); break; } } for (int i = 1;i < n;i++) { if (ans.back() != i) q.push(i); } while (!q.empty()) { if (adj[ans.back()][q.front()]) { ans.push_back(q.front()); q.pop(); } else { int v = ans.back(); ans.pop_back(); ans.push_back(q.front()); q.pop(); ans.push_back(v); } } vector<int> Ans; while (!ans.empty()) Ans.push_back(ans.front()), ans.pop_front(); return Ans; }
#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...