# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549666 | 2022-04-16T08:43:11 Z | AJ00 | Library (JOI18_library) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "library.h" using namespace std; int n; vector<int> res; vector<vector<int>> adj(1001); void dfs(int x, int p = 0){ res.push_back(x); for (int ch: adj[x]){ if (ch != p){ dfs(ch,x); } } } void Solve(int N){ n = N; vector<int> M(n); if (n == 1){ res.push_back(1); Answer(res); continue; } for (int i = 1; i <= n; i++){ for (int j = i+1; j <= n; j++){ fill(M.begin(),M.end(),0); M[i-1] = 1; M[j-1] = 1; int ans = Query(M); if (ans == 1){ adj[i].push_back(j); adj[j].push_back(i); } } } for (int i = 1; i <= n; i++){ if (adj[i].size() == 1){ dfs(i); break; } } Answer(res); }