Submission #967310

# Submission time Handle Problem Language Result Execution time Memory
967310 2024-04-21T20:08:27 Z AtabayRajabli Floppy (RMI20_floppy) C++17
0 / 100
68 ms 13628 KB
#include <bits/stdc++.h>
using namespace std;
#include "floppy.h"

void read_array(int subtask_id, const vector<int> &v) {
    string bits = "";
    stack<int> st;
    for(int i = 0; i < v.size(); i++)
    {
        while(!st.empty() && v[i] > st.top())
        {
            bits += '0';
            st.pop();
        }
        bits += '1';
        st.push(v[i]);
    }
    while(!st.empty())
    {
        bits += '0';
        st.pop();
    }
    save_to_floppy(bits);
}

vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) {
    vector<int> st;
    int ind = 0;
    vector<int> res(a.size());
    vector<array<int, 2>> nd[N];
    for(int i = 0; i < a.size(); i++)
    {
        nd[b[i]].push_back({a[i], i});
    }
    for(int i = 0; i < N; i++) sort(nd[b[i]].begin(), nd[b[i]].end());
    for(int i = 0; i < N; i++)
    {
        while(bits[ind] == '0')
        {
            st.pop_back();
            ind++;
        }
        while(!nd[i].empty() && nd[i].back()[1] > st.back())
        {
            res[nd[i].back()[1]] = i;
            nd[i].pop_back();
        }
        st.push_back(i), ind++;
    }
    return res;
}

Compilation message

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     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:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0; i < a.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 Runtime error 2 ms 1076 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 21 ms 4856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 13628 KB Output isn't correct
2 Halted 0 ms 0 KB -