Submission #642615

# Submission time Handle Problem Language Result Execution time Memory
642615 2022-09-20T09:17:22 Z TimDee Floppy (RMI20_floppy) C++17
0 / 100
39 ms 5216 KB
#include "floppy.h"
#include <bits/stdc++.h>
using namespace std;

void read_array(int subtask_id, const std::vector<int> &V) {
    vector<int> v=V;
    if (subtask_id==3) exit(0);
    int n=v.size();
    vector<pair<int,int>> a(n);
    for (int i=0; i<n; ++i) {
        a[i]={v[i],i};
    }
    sort(a.begin(), a.end());
    for (int i=0; i<n; ++i) {
        v[a[i].second]=i;
    }

    int k=log2(n);
    string s;
    for (int i=0; i<n; ++i) {
        string t;
        for (int bit=k; bit>=0; --bit) {
            t+=('0'+((v[i]>>bit)&1));
        }
        s+=t;
    }

    save_to_floppy(s);

}

vector<int> t;
vector<int> A;
int sz=1, neutr; 

int merge (int i, int j) {
    if (A[i]>A[j]) return i;
    else return j;
}

void update(int i, int l, int r) {
    if (r-l==1) return;
    int mid=(l+r)>>1;
    update(2*i+1,l,mid);
    update(2*i+2,mid,r);
    t[i]=merge(t[2*i+1],t[2*i+2]);
}

int query(int i, int l, int r, int lx, int rx) {
    if (l>=rx) return neutr;
    if (r<=lx) return neutr;
    if (l>=lx && r<=rx) return t[i];
    int mid=(l+r)>>1;
    int L=query(2*i+1,l,mid,lx,rx), R=query(2*i+2,mid,r,lx,rx);
    return merge(L,R);
}

int query(int l, int r) {
    return query(0,0,sz,l,r);
}

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,m=a.size();
    int k=log2(n); while (sz<n) sz<<=1;
    t.assign(2*sz-1,n);
    string s=bits;
    vector<int> v(n);
    for (int i=0; i<1ll*n*(k+1); i+=k+1) {
        int x=0;
        for (int bit=k; bit>=0; --bit) {
            x+=((s[i+k-bit]=='1')<<bit);
        }
    }
    neutr=n;
    v.push_back(-INT_MAX);
    A=v;
    for (int i=0; i<n; ++i) t[sz-1+i]=i;
    update(0,0,sz);
    vector<int> ans(m,0);
    for (int q=0; q<m; ++q) {
        int l=a[q], r=b[q];
        ans[q]=query(l,r+1);
    }
    return ans;
}

Compilation message

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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 4328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 5216 KB Didn't terminate properly.
2 Halted 0 ms 0 KB -