#include "bits/stdc++.h"
#include "library.h"
using namespace std;
#define pb push_back
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(n, 0);
vector<bool> visited(n+1, false);
for(int i = 1; i<=n; i++)
{
if((int)adj[i].size()==1)
{
res[0] = i;
visited[res[0]] = true;
break;
}
}
for(int i = 1; i<=n; i++)
{
if((int)adj[i].size()==1&&res[0]!=i)
{
res[n-1] = i;
visited[res[n-1]] = true;
break;
}
}
for(int i = 1; i<n-1; i++)
{
int x = res[i-1];
if((int)adj[x].size()==1)
{
res[i] = adj[x][0];
visited[res[i]] = true;
}
else
{
for(auto v: adj[x])
{
if(visited[v])
continue;
res[i] = v;
visited[v] = true;
}
}
}
Answer(res);
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
331 ms |
492 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
331 ms |
492 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |