Submission #48272

#TimeUsernameProblemLanguageResultExecution timeMemory
48272marvenleeLibrary (JOI18_library)C++14
0 / 100
3 ms376 KiB
#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)

library.cpp: In function 'void Solve(int)':
library.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 while(finalans.size()!=n)
       ~~~~~~~~~~~~~~~^~~
library.cpp:35:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<finalans.size();i++)
                     ~^~~~~~~~~~~~~~~~
library.cpp:42:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<finalans.size();i++)
                     ~^~~~~~~~~~~~~~~~
library.cpp:61:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<check.size()/2;i++)
                     ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...