답안 #475261

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
475261 2021-09-21T17:04:39 Z stefantaga Floppy (RMI20_floppy) C++14
28 / 100
1000 ms 12712 KB
#include <stdlib.h>
#include <string.h>
#include <bits/stdc++.h>
#include "floppy.h"

using namespace std;
int v[40005],n;
stack <int> st;
void read_array(int subtask_id, const std::vector<int> &x) {
    std::string  bits;
    n=x.size();
    int i;
    for (i=1;i<=n;i++)
    {
        v[i]=x[i-1];
    }
    for (i=1;i<=n;i++)
    {
        while (!st.empty()&&v[st.top()]<v[i])
        {
            st.pop();
            bits+="1";
        }
        st.push(i);
        bits+="0";
    }
    save_to_floppy(bits);
}
int stanga[50005];
vector <pair <int,int> >  queryuri;
std::vector<int> solve_queries(int subtask_id, int N,
        const std::string &bits,
        const std::vector<int> &a, const std::vector<int> &b) {
    n=N;
    int i,poz;
    while (!st.empty())st.pop();
    poz=1;
    for (i=0;i<bits.size();i++)
    {
        if (bits[i]=='0')
        {
            if (st.empty())
            {
                stanga[poz]=0;
            }
            else
            {
                stanga[poz]=st.top();
            }
            st.push(poz);
            poz++;
        }
        else
        {
            st.pop();
        }
    }
    for (i=0;i<a.size();i++)
    {
        queryuri.push_back({a[i]+1,b[i]+1});
    }
    vector <int> answers;
    for (i=0;i<queryuri.size();i++)
    {
        int minim=1e9,pozitie=0;
        for (int j=queryuri[i].first;j<=queryuri[i].second;j++)
        {
            if (stanga[j]<=minim)
            {
                minim=stanga[j];
                pozitie=j-1;
            }
        }
        answers.push_back(pozitie);
    }
    return answers;
}

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:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (i=0;i<bits.size();i++)
      |              ~^~~~~~~~~~~~
floppy.cpp:58:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (i=0;i<a.size();i++)
      |              ~^~~~~~~~~
floppy.cpp:63:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for (i=0;i<queryuri.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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 652 KB Output is correct
2 Correct 2 ms 652 KB Output is correct
3 Correct 2 ms 788 KB Output is correct
4 Correct 2 ms 784 KB Output is correct
5 Correct 2 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 3480 KB Output is correct
2 Correct 57 ms 3456 KB Output is correct
3 Correct 104 ms 3444 KB Output is correct
4 Correct 97 ms 3564 KB Output is correct
5 Correct 61 ms 3460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 613 ms 12712 KB Output is correct
2 Correct 614 ms 12612 KB Output is correct
3 Execution timed out 1109 ms 12604 KB Time limit exceeded
4 Halted 0 ms 0 KB -