# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
744280 | MON | Library (JOI18_library) | C++14 | 564 ms | 308 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;
void Solve(int N)
{
vector<int> m(N,0);
if(N <= 2)
{
vector<int> ans;
if(N == 1) ans = {1};
else ans = {1,2};
Answer(ans);return;
}
vector<int> vecini[N]; int luat[N] = {0};
for(int i = 0 ; i < N - 1 ; i++)
{
for(int j = i + 1 ; j < N ; j++)
{
fill(m.begin(),m.end(),0);
m[i] = m[j] = 1;
int sunt = Query(m); if(sunt != 1) sunt = 0;
if(sunt)
{
vecini[i].emplace_back(j);
vecini[j].emplace_back(i);
}
}
}
vector<int> ans;
for(int i = 0; i < N ; i++)
{
if(vecini[i].size() == 1)
{
ans.emplace_back(i);
luat[i] = 1; break;
}
}
while(ans.size() < N)
{
for(auto &it : vecini[ans.back()])
{
if(!luat[it])
{
luat[it] = 1;
ans.emplace_back(it);
break;
}
}
}
for(auto &it : ans) it++;
Answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |