제출 #1218020

#제출 시각아이디문제언어결과실행 시간메모리
1218020KindaGoodGamesFloppy (RMI20_floppy)C++20
7 / 100
21 ms3324 KiB
#include <stdlib.h> #include <string.h> #include<bits/stdc++.h> #include "floppy.h" using namespace std; int B = 31; int INF = numeric_limits<int>::max()/2; void read_array(int subtask_id, const std::vector<int> &v) { // int len = 1; int n = v.size(); // while(len < n) len <<= 1; // vector<int> S(2*len); // for(int i = 0; i < n; i++){ // S[i+len] = v[i]; // } // for(int i = len-1; i > 0; i--){ // S[i] = max(S[i*2], S[i*2+1]); // } string bits = ""; for(int i = 0; i < n; i++){ char c = (('0')+ (v[i] < 0)); bits += c; for(int k = 0; k < B; k++){ bool on = ((1<<k)&v[i]); bits += ('0'+on); } } 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 = bits.size()/(B+1); vector<int> vec(n); for(int i = 0; i < n; i++){ for(int k = ((B+1)*i)+1; k < (B+1)*(i+1); k++){ bool on = bits[k] == '1'; int pos =(1<<k-( ((B+1)*i)+1)); 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...