#include "bits/stdc++.h"
#include "library.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
void Solve(int n)
{
vector<pair<int, int>> arr;
vector<int> m(n, 0);
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 cnt = Query(m);
if(cnt==2)
{
arr.pb(mp(i, j));
}
}
}
vector<int> adj[n+1];
for(int i = 0; i<(int)arr.size(); i++)
{
adj[arr[i].fi].pb(arr[i].se);
adj[arr[i].se].pb(arr[i].fi);
}
int beg = 1;
for(int i = 1; i<=n; i++)
{
if((int)adj[i].size()==1)
{
beg = 1;
break;
}
}
vector<bool> visited(n+1, false);
queue<int> q;
q.push(beg);
visited[beg] = true;
vector<int> res;
while(!q.empty())
{
int u = q.front();
q.pop();
res.pb(u);
for(auto v: adj[u])
{
if(visited[v])
continue;
visited[v] = true;
q.push(v);
}
}
Answer(res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
266 ms |
660 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
266 ms |
660 KB |
Wrong Answer [8] |
2 |
Halted |
0 ms |
0 KB |
- |