Submission #1056954

# Submission time Handle Problem Language Result Execution time Memory
1056954 2024-08-13T12:40:42 Z kititnik Floppy (RMI20_floppy) C++14
0 / 100
44 ms 8832 KB
#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
 
void read_array(int sub, const vector<int> &v) {
    string bits;
    stack<int> st;
    for(int i = 0; i < v.size(); i++)
    {
        while(!st.empty() && v[i] > v[st.top()])
        {
            st.pop();
            bits += "0";
        }
        st.push(i);
        bits += "1";
    }
    save_to_floppy(bits);
}

vector<int> solve_queries(int sub, int n, const string &bits, const vector<int> &a, const vector<int> &b) {
    vector<int> ans;
    for(int q = 0; q < a.size(); q++)
    {
        deque<int> qu;
        int zeros = 0;
        for(int i = 0; i <= a[q]; i++)
        {
            if(bits[i] == '0') zeros++;
        }
        int start = a[q] + zeros;
        int end = b[q]+zeros;
        int p = start;
        for(int i = start; i <= end; i++)
        {
            while(bits[p] == '0')
            {
                qu.pop_back();
                p++;
            }
            qu.push_back(i-zeros);
            p++;
        }
        ans.push_back(qu.front());
    }
    return ans;
}

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:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int q = 0; q < a.size(); q++)
      |                    ~~^~~~~~~~~~
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 1 ms 800 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 2976 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 44 ms 8832 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -