#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);
}
}
}
vector<int> res(n, 0);
for(int i = 1; i<=n; i++)
{
if((int)adj[i].size()==1)
{
res[0] = i;
break;
}
}
for(int i = 1; i<=n; i++)
{
if((int)adj[i].size()==1&&res[0]!=i)
{
res[n-1] = i;
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];
}
else
{
if(adj[x][0]==res[i-2])
res[i] = adj[x][1];
else
res[i] = adj[x][0];
}
}
Answer(res);
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
363 ms |
832 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
363 ms |
832 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |