Submission #926059

# Submission time Handle Problem Language Result Execution time Memory
926059 2024-02-12T14:00:49 Z vjudge1 Floppy (RMI20_floppy) C++17
28 / 100
1000 ms 11452 KB
#include <bits/stdc++.h>
#include "floppy.h"

using namespace std;

void get_bits(string &result, int l, int r, const vector<int> &v){
    int pos = max_element(v.begin() + l, v.begin() + r + 1) - v.begin();
    if (l == pos) result += '0';
    else{
        result += '1';
        get_bits(result, l, pos-1, v);
    }

    if (pos == r) result += '0';
    else{
        result += '1';
        get_bits(result, pos+1, r, v);
    }
}
void read_array(int subtask_id, const vector<int> &v){
    string result;
    get_bits(result, 0, v.size()-1, v);
    save_to_floppy(result);
}

void read_bits(vector<int> &v, const string &result, int &ptr, int depth){
    char posl = result[ptr++];
    if (posl == '1'){
        read_bits(v, result, ptr, depth+1);
    }

    v.push_back(depth);

    char posr = result[ptr++];
    if (posr == '1'){
        read_bits(v, result, ptr, depth+1);
    }
}
vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b){
    vector<int> s; int ptr = 0;
    read_bits(s, bits, ptr, 0);
    vector<int> result(a.size());
    for (int i=0; i<result.size(); i++){
        result[i] = min_element(s.begin() + a[i], s.begin() + b[i] + 1) - s.begin();
    }
    return result;
}

Compilation message

floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:43:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i=0; i<result.size(); i++){
      |                   ~^~~~~~~~~~~~~~
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 1 ms 828 KB Output is correct
2 Correct 1 ms 828 KB Output is correct
3 Correct 2 ms 824 KB Output is correct
4 Correct 2 ms 812 KB Output is correct
5 Correct 1 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 3504 KB Output is correct
2 Correct 87 ms 3492 KB Output is correct
3 Correct 228 ms 3668 KB Output is correct
4 Correct 158 ms 3656 KB Output is correct
5 Correct 86 ms 3504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1099 ms 11452 KB Time limit exceeded
2 Halted 0 ms 0 KB -