Submission #907164

#TimeUsernameProblemLanguageResultExecution timeMemory
907164ibm2006Minerals (JOI19_minerals)C++17
80 / 100
33 ms5772 KiB
#include "minerals.h" #include<bits/stdc++.h> using namespace std; typedef int ll; ll n,i,j,k,l,r,x,y,z,w,s,t,perm[1100000],b[1100000]; vector<ll> v,u; void dnc(vector<ll> v,vector<ll> u,ll z) { //printf("(%lld %lld)\n",v.size(),u.size()); ll i,m=v.size(); ll mid=m/2,x,y; vector<ll> v1,v2,u1,u2; if(m==1) { perm[v[0]]=u[0]; return; } /*if(m==2) { if(z==0) {for(i=0;i<mid;i++) { //printf("! %lld\n",v[i]); x=Query(v[i]); s++; }} else { for(i=mid;i<m;i++) { //printf("! %lld\n",v[i]); x=Query(v[i]); s--; } } for(i=0;i<mid;i++) { v1.push_back(v[i]); } for(i=mid;i<m;i++) { v2.push_back(v[i]); } x=s-x; y=Query(u[0]); if(b[u[0]]==0) s++; else s--; b[u[0]]^=1; y=s-y; //printf("(%lld)\n",y); if(y!=x) {u1.push_back(u[0]); u2.push_back(u[1]); } else {u2.push_back(u[0]); u1.push_back(u[1]); } // printf("! %lld\n",u[i]); x=y; dnc(v2,u2,0); dnc(v1,u1,1); return; }*/ if(z==0) {for(i=0;i<mid;i++) { //printf("! %lld\n",v[i]); x=Query(v[i]); s++; }} else { for(i=mid;i<m;i++) { //printf("! %lld\n",v[i]); x=Query(v[i]); s--; } } for(i=0;i<mid;i++) { v1.push_back(v[i]); } for(i=mid;i<m;i++) { v2.push_back(v[i]); } x=s-x; for(i=0;i<m;i++) { if(i==m-1) { if(u1.size()<mid) { u1.push_back(u[i]); } else u2.push_back(u[i]); continue; } //printf("! %lld\n",u[i]); y=Query(u[i]); if(b[u[i]]==0) s++; else s--; b[u[i]]^=1; y=s-y; //printf("(%lld)\n",y); if(y!=x) u1.push_back(u[i]); else u2.push_back(u[i]); // printf("! %lld\n",u[i]); x=y; } dnc(v2,u2,0); dnc(v1,u1,1); } void f() { ll i,x=0,y; for(i=1;i<=n*2;i++) { y=Query(i); s++; if(y>x) { v.push_back(i); x++; continue; } else { Query(i); s--; u.push_back(i); continue; } } } void Solve(ll N) { n=N; f(); /*for(i=0;i<v.size();i++) { Query(v[i]); }*/ dnc(v,u,1); for(i=1;i<=n*2;i++) { if(perm[i]==0) continue; Answer(i,perm[i]); } }

Compilation message (stderr)

minerals.cpp: In function 'void dnc(std::vector<int>, std::vector<int>, ll)':
minerals.cpp:97:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   97 |             if(u1.size()<mid)
      |                ~~~~~~~~~^~~~
minerals.cpp:92:6: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   92 |     x=s-x;
      |     ~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...