Submission #826750

#TimeUsernameProblemLanguageResultExecution timeMemory
826750jamezzzAncient Machine 2 (JOI23_ancient2)C++17
10 / 100
30 ms452 KiB
#include "ancient2.h" #include <bits/stdc++.h> using namespace std; #define pf printf #define pb push_back #define sz(x) ((int)x.size()) string Solve(int N){ int know=0; string ans=""; while(know!=N){ vector<int> a,b; for(int i=0;i<know;++i){ a.pb(i+1); b.pb(i+1); } int cur=know,num=1; while(cur+3*num<=1002&&know!=N){ int ptr=cur+num; for(int i=cur;i<cur+num;++i){ a.pb(ptr++); b.pb(ptr++); } cur=cur+num; num*=2; ++know; } for(int i=cur;i<cur+num;++i){ a.pb(i),b.pb(i); } //pf("%d:\n",sz(a)); //for(int i:a)pf("%d ",i);pf("\n"); //for(int i:b)pf("%d ",i);pf("\n"); int res=Query(sz(a),a,b); res-=cur; vector<char> v; while(num!=1){ v.pb((res&1)+'0'); res>>=1; num>>=1; } while(!v.empty()){ ans.pb(v.back()); //pf("add %c\n",v.back()); v.pop_back(); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...