Submission #1056294

# Submission time Handle Problem Language Result Execution time Memory
1056294 2024-08-13T08:42:27 Z shiocan Floppy (RMI20_floppy) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
/*
    #define cin fin
    #define cout fout
    string __fname = ""; ifstream fin(__fname + ".in"); ofstream fout(__fname + ".out");
*/

#define ull unsigned long long 
#define ll long long
//#define int long long
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
int mod = 1e9 + 7; 
//const int inf = 1e18;
const int N = 2e5 + 100;

#include "floppy.h"

void read_array( int subtask_id , const std :: vector<int> &v){
    int n = v.size();

    string bits = "";

    for(int i = 0; i < n; i++)
        for(int j = i; j < n; j++)
            if(v[i] >= v[j])
                bits.push_back('1');
            else    
                bits.push_back('0');

    save_to_floppy(bits);
}

pii get_idx(int l, int r, int n){
    int posl = ((n - l) + n) * (n - (n - l) + 1) / 2;

    posl -= (n - l);
    int dis = r - l;
    int posr = posl + dis;

    return {posl, posr};
}

int solve(int l, int r, int n, const string bits){

    if(l == r){
        return l;
    }

    // cout << l << ' ' << r << '\n';
    for(int i = l; i <= r; i++){
        if(bits[i] == '0'){
            int posl = i - l + 1;

            pii idx = get_idx(posl, r, n);
            
            return solve(idx.first, r, n, bits);
        }
    }


    return l;
}

vector<int> solve_queries ( int subtask_id,
    int N, const std :: string &bits,
    const std :: vector<int> &a,
    const std :: vector<int> &b){

    int q = a.size();
    vector<int> ans;

    int n = N;


    for(int i = 0; i < q; i++){
        int l = a[i], r = b[i];

        if(a[i] == b[i]){
            ans.push_back(l);
            continue;
        }

        pii idx = get_idx(l, r, n);
        int x = solve(idx.first, idx.second, n, bits);

        int res = 0;
        while(x >= (n - res)){
            x -= (n - res);
            res++;
        }

        ans.push_back(res);
    }

    return ans;
}   

// grading

void solve(){       
    read_array(3, {40, 20, 30, 10});

    string aux = "1111101111";

    vector<int> q = solve_queries(3, 4, aux, {0, 0, 0, 0, 1, 1, 1, 2, 2, 3}, {0, 1, 2, 3, 1, 2, 3, 2, 3, 3});
    // q = solve_queries(3, 4, aux_bits, {0}, {3});
    cout << '\n';
    for(auto i : q)
        cout << i << ' ';
    cout << '\n';
}      

int32_t main(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccQuigyk.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccIbM0ej.o:floppy.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status