Submission #857050

# Submission time Handle Problem Language Result Execution time Memory
857050 2023-10-05T10:19:01 Z busamate Floppy (RMI20_floppy) C++14
100 / 100
82 ms 15704 KB
#include <stdlib.h>
#include <string.h>
#include <set>

#include "floppy.h"

using namespace std;

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

    int tart = 0;
    set<int> szet;
    szet.clear();
    for (int i = 0; i < N; i++)
    {
        while (!szet.empty() && v[*szet.rbegin()] < v[i])
        {
            bits[tart++] = '1';
            auto it = szet.end();
            it--;
            szet.erase(it);
        }
        szet.insert(i);
        tart++;
    }

    save_to_floppy(bits);
}

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);

    vector<int> kerd[40000];
    for (int i = 0; i < N; i++)
        kerd[i].clear();

    for (int i = 0; i < Q; i++)
        kerd[bb[i]].push_back(i);

    set<int> szet;
    szet.clear();
    int tart = 0;
    for (int i = 0; i < N; i++)
    {
        while (bits[tart] == '1')
        {
            auto it = szet.end();
            it--;
            szet.erase(it);
            tart++;
        }
        tart++;
        szet.insert(i);
        for (int j : kerd[i])
        {
            ans[j] = (*szet.lower_bound(aa[j]));
        }
    }

    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 Correct 2 ms 1840 KB Output is correct
2 Correct 2 ms 1852 KB Output is correct
3 Correct 2 ms 1852 KB Output is correct
4 Correct 2 ms 1852 KB Output is correct
5 Correct 2 ms 1848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3572 KB Output is correct
2 Correct 19 ms 4548 KB Output is correct
3 Correct 22 ms 5056 KB Output is correct
4 Correct 20 ms 4620 KB Output is correct
5 Correct 18 ms 4532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 9800 KB Output is correct
2 Correct 74 ms 13128 KB Output is correct
3 Correct 82 ms 15704 KB Output is correct
4 Correct 77 ms 13624 KB Output is correct
5 Correct 77 ms 13116 KB Output is correct