Submission #923886

# Submission time Handle Problem Language Result Execution time Memory
923886 2024-02-08T04:38:04 Z vjudge1 Floppy (RMI20_floppy) C++17
100 / 100
77 ms 21820 KB
#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
void read_array(int subtask_id, const std::vector<int> &v) {
    string res = "";
    stack<int> t;
    for (int i = 0; i < v.size(); i++) {
        while (!t.empty() && t.top() <= v[i]) {
            res += '0';
            t.pop();
        }
        t.push(v[i]);
        res += '1';
    }
    save_to_floppy(res);
}
vector<int> g[200005];
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 = bits.size(), q = a.size(), c = 0;
    vector<int> v, res(q);
    for (int i = 0; i < q; i++) {
        g[b[i]].push_back(i);
    }
    for (int i = 0; i < N; i++) {
        while (bits[c] == '0') {
            v.pop_back();
            c++;
        }
        v.push_back(i);
        for (int j = 0; j < g[i].size(); j++) {
            res[g[i][j]] = *lower_bound(v.begin(), v.end(), a[g[i][j]]);
        }
        c++;
    }
    return res;
}

Compilation message

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:7:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:30:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int j = 0; j < g[i].size(); j++) {
      |                         ~~^~~~~~~~~~~~~
floppy.cpp:19:9: warning: unused variable 'n' [-Wunused-variable]
   19 |     int n = bits.size(), q = a.size(), c = 0;
      |         ^
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 3 ms 10040 KB Output is correct
2 Correct 3 ms 10048 KB Output is correct
3 Correct 3 ms 10036 KB Output is correct
4 Correct 4 ms 10240 KB Output is correct
5 Correct 3 ms 10052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 13056 KB Output is correct
2 Correct 19 ms 12980 KB Output is correct
3 Correct 23 ms 12956 KB Output is correct
4 Correct 18 ms 12964 KB Output is correct
5 Correct 19 ms 13248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 21772 KB Output is correct
2 Correct 67 ms 21776 KB Output is correct
3 Correct 69 ms 21816 KB Output is correct
4 Correct 68 ms 21800 KB Output is correct
5 Correct 66 ms 21820 KB Output is correct