#include<bits/stdc++.h>
#include "floppy.h"
using namespace std;
string s;
int curr;
vector<long long> vv;
map<long long,int> mp;
/*
void save_to_floppy(string ss){
}
*/
void read_array(int subtask_id,const vector<int> &v){
for(int i=0;i<v.size();i++){
vv.push_back(v);
}
sort(vv.begin(),vv.end());
for(int i=0;i<vv.size();i++){
mp[vv[i]]=i;
}
for(int i=0;i<v.size();i++){
curr=mp[v[i]];
for(int f=0;f<15;f++){
s.push_back(curr%2+'0');
curr/=2;
}
}
save_to_floppy(s);
}
int c[80007],p,st;
bool li[80007][20];
int dp[80007][20];
int power[20],lg[80007];
void calc(){
power[0]=1;
for(int i=1;i<20;i++)power[i]=power[i-1]*2;
lg[1]=0;
for(int i=2;i<=80000;i++)lg[i]=lg[i/2]+1;
}
int best(int x,int y){
if(c[x]>c[y])return x;
else return y;
}
int rmq(int i,int j){
if(j==0)return i;
if(li[i][j])return dp[i][j];
li[i][j]=true;
dp[i][j]=best(rmq(i,j-1),rmq(i+power[j-1],j-1));
return dp[i][j];
}
int mins(int l,int r){
return best( rmq(l,lg[r-l+1]) , rmq(r-power[lg[r-l+1]]+1,lg[r-l+1]) );
}
vector<int> ans;
vector<int> solve_queries(int subtask_id,int N,const string &bits,const vector<int> &a,const vector<int> &b){
for(int i=0;i<bits.size();i+=15){
st=1;
for(int f=i;f<=i+14;f++){
c[p]+=st*(bits[f]-'0');
st*=2;
}
p++;
}
calc();
for(int i=0;i<a.size();i++){
ans.push_back(mins(a[i],b[i]));
}
return ans;
}
/*
int main(){
vector<int> w;
read_array(0,{40, 20, 30, 10 } );
w=solve_queries(0,4,s,{0, 0, 0, 0, 1, 1, 1, 2, 2, 3} , {0, 1, 2, 3, 1, 2, 3, 2, 3, 3 });
for(int i=0;i<w.size();i++){
cout<<w[i]<<" ";
}
}
*/
Compilation message
floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
floppy.cpp:18:23: error: no matching function for call to 'std::vector<long long int>::push_back(const std::vector<int>&)'
18 | vv.push_back(v);
| ^
In file included from /usr/include/c++/10/vector:67,
from /usr/include/c++/10/queue:61,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
from floppy.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
1187 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note: no known conversion for argument 1 from 'const std::vector<int>' to 'const value_type&' {aka 'const long long int&'}
1187 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>; std::vector<_Tp, _Alloc>::value_type = long long int]'
1203 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note: no known conversion for argument 1 from 'const std::vector<int>' to 'std::vector<long long int>::value_type&&' {aka 'long long int&&'}
1203 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~~
floppy.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i=0;i<vv.size();i++){
| ~^~~~~~~~~~
floppy.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | for(int i=0;i<v.size();i++){
| ~^~~~~~~~~
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:69:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
69 | for(int i=0;i<bits.size();i+=15){
| ~^~~~~~~~~~~~
floppy.cpp:78:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | for(int i=0;i<a.size();i++){
| ~^~~~~~~~~
stub.cpp: In function 'void run2()':
stub.cpp:101:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
101 | if (query_answers.size() != M) {
| ~~~~~~~~~~~~~~~~~~~~~^~~~