#include <stdlib.h>
#include <string.h>
#include<bits/stdc++.h>
#include "floppy.h"
using namespace std;
int B = 14;
int INF = numeric_limits<int>::max()/2;
void read_array(int subtask_id, const std::vector<int> &arr) {
vector<int >v = arr;
int n = v.size();
vector<int> sorted = v;
sort(sorted.begin(),sorted.end());
map<int,int>toInd;
for(int i = 0; i < n; i++){
toInd[sorted[i]] = i;
}
for(int i = 0; i < n; i++){
v[i] = toInd[v[i]];
}
string bits = "";
for(int i = 0; i < n; i++){
for(int k = 0; k < B; k++){
bool on = ((1<<k)&v[i]);
bits += ('0'+on);
}
}
cerr << bits<<endl;
save_to_floppy(bits);
}
std::vector<int> solve_queries(int subtask_id, int N, const std::string &bits, const std::vector<int> &a, const std::vector<int> &b) {
int n = N;
vector<int> vec(n);
for(int i = 0; i < n; i++){
for(int k = (B*i); k < B*(i+1); k++){
bool on = bits[k] == '1';
int pos =(1<<k-( (B*i)));
vec[i] += on* pos;
}
}
int q = a.size();
vector<int> answers(q);
for(int t = 0; t < q; t++){
int l = a[t];
int r = b[t];
int ma = -INF;
int maInd = -1;
for(int i = l; i <= r; i++){
if(ma < vec[i]){
ma = vec[i];
maInd = i;
}
}
answers[t] = maInd;
}
return answers;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |