# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48272 | marvenlee | Library (JOI18_library) | C++14 | 3 ms | 376 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 <bits/stdc++.h>
#include "library.h"
using namespace std;
void Solve(int n)
{
vector<int> m(n);
vector<int>finalans;
int n1=n;
n--;
int sizeofn=1;
while(n!=1)
{
sizeofn +=1;
n/=2;
}
n=n1;
while(finalans.size()!=n)
{
int binary[n];
for(int i = 0; i < n; i++) {
binary[i]=i;
}
int difference=0;
vector<int> check(n);
vector<int> m1;
for(int i=0;i<n;i++)
{
if(binary[i]%2==1) m[i]=1;
else m[i]=0;
for(int i=0;i<finalans.size();i++)
{
m[finalans[i]]=0;
}
int a=Query(m);
if(m[i]==0) m[i]=1;
else m[i]=0;
for(int i=0;i<finalans.size();i++)
{
m[finalans[i]]=0;
}
int b=Query(m);
if(a==b)
{
difference+=pow(2,i);
m1=m;
}
}
vector<int>m2;
for(int i=0;i<n;i++)
{
if (m1[i]==1) check.push_back(i);
}
m2=m1;
while(check.size()!=1)
{
for(int i=0;i<check.size()/2;i++)
{
m1[check[i]]=0;
m2[check[i]]=1;
}
int a= Query(m1);
int b= Query(m2);
if(a!=b)
check.erase(check.begin(),check.begin()+check.size()/2);
else
check.erase(check.begin()+check.size()/2,check.end());
}
int x=check[0];
int y=x^difference;
m.assign(n,0);
m[x]=1;
m[finalans.size()/2 -1]=1;
if(Query(m)!=1)
{
int z=x;
x=y;
y=z;
}
finalans.insert(finalans.begin()+finalans.size()/2,y);
finalans.insert(finalans.begin()+finalans.size()/2,x);
}
Answer(finalans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |