# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101319 | 2019-03-18T12:44:10 Z | b2563125 | Library (JOI18_library) | C++14 | 0 ms | 0 KB |
#include<iostream> #include<vector> #include<string> #include<stack> #include<queue> #include<utility> #include<algorithm> using namespace std; #define vel vector<int> #define vvel vector<vel> #define vvvel vector<vvel> #define veb vector<bool> void mmax(int &a, int b) { a = max(a, b); } bool che(int i, int j, int n) { vel a(n, 0); a[i] = 1; a[j] = 1; return Query(a) == 1; } void Solve(int n) { if (n == 1) { vel res(1, 1); Answer(res); } vvel con(n); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (che(i, j,n)) { con[i].push_back(j); con[j].push_back(i); } } } int th; for (int i = 0; i < n; i++) { if (con[i].size() == 1) { th = i; } } veb seen(false); seen[th] = true; vel ans(1, th + 1); th = con[th][0]; while (con[th].size() > 1) { ans.push_back(th + 1); if (seen[con[th][0]]) { th = con[th][1]; } else { th = con[th][0]; } } ans.push_back(th + 1); Answer(ans); }