#include "bits/stdc++.h"
#include "library.h"
using namespace std;
#define pb push_back
void dfs(vector<int> adj[], vector<bool> &visited, int u, vector<int> &res)
{
res.pb(u);
visited[u] = true;
for(auto v: adj[u])
{
if(!visited[v])
{
dfs(adj, visited, v, res);
}
}
}
void Solve(int n)
{
vector<int> m(n);
vector<int> adj[n+1];
for(int i = 1; i<=n; i++)
{
for(int j = i+1; j<=n; j++)
{
m.assign(n, 0);
m[i-1] = 1, m[j-1] = 1;
int curr = Query(m);
if(curr==2)
{
adj[i].pb(j);
adj[j].pb(i);
}
}
}
/*for(int i = 1; i<=n; i++)
{
cout << i << ": ";
for(auto v: adj[i])
cout << v << ' ';
cout << endl;
}*/
vector<int> res;
vector<bool> visited(n+1, false);
int beg = 1;
for(int i = 1; i<=n; i++)
{
if((int)adj[i].size()==1)
{
beg = i;
break;
}
}
dfs(adj, visited, beg, res);
Answer(res);
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
387 ms |
440 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
387 ms |
440 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |