Submission #857039

# Submission time Handle Problem Language Result Execution time Memory
857039 2023-10-05T09:35:57 Z busamate Floppy (RMI20_floppy) C++17
0 / 100
24 ms 6868 KB
#include <stdlib.h>
#include <string.h>

#include "floppy.h"

using namespace std;

void read_array(int subtask_id, const std::vector<int> &v)
{
    int N = v.size();
    string bits('0', 2 * N);

    int tart = 0;
    vector<int> pos;
    pos.clear();
    for (int i = 0; i < N; i++)
        pos.push_back(i);

    while (pos.size() > 1)
    {
        vector<int> uj;
        uj.clear();

        int pre = -1;
        bool ok = false;
        for (int i : pos)
        {
            if (pre == -1)
            {
                ok = true;
            }
            else if (v[pre] < v[i])
            {
                ok = true;
                bits[tart++] = '1';
            }
            else
            {
                if (ok)
                    uj.push_back(pre);
                ok = false;
                bits[tart++] = '0';
            }
            pre = i;
        }
        if (ok)
            uj.push_back(pre);
        pos = uj;
    }

    save_to_floppy(bits);
}

vector<int> kerd[40000];

std::vector<int> solve_queries(int subtask_id, int N,
                               const std::string &bits,
                               const std::vector<int> &aa, const std::vector<int> &bb)
{
    int Q = aa.size();
    std::vector<int> ans(Q);

    for (int i = 0; i < Q; i++)
    {
        kerd[bb[i]].push_back(i);
        if (aa[i] == bb[i])
            ans[i] = aa[i];
    }

    vector<int> pos;
    pos.clear();
    for (int i = 0; i < N; i++)
        pos.push_back(i);

    int tart = 0;
    while (pos.size() > 1)
    {
        vector<int> uj;
        uj.clear();
        int pre = -1;
        bool ok = false;
        for (int i : pos)
        {
            if (pre == -1)
            {
                ok = true;
            }
            else if (bits[tart++] == '0')
            {
                if (ok)
                    uj.push_back(pre);
                ok = false;
            }
            else
            {
                ok = true;
            }
            pre = i;
        }
        if (ok)
            uj.push_back(pre);
        pos = uj;

        int a = -1, b = -1;
        auto it = pos.begin();
        for (int i = 0; i < N; i++){
            if(it!=pos.end() && (*it)==i){
                a = b;
                b = i;
                it++;
            }
            for(int j : kerd[i]){
                if(a < aa[j] && aa[j] <= b)
                    ans[j] = b;
            }
        }
    }

    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 Runtime error 2 ms 2392 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 3808 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 6868 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -