답안 #638999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638999 2022-09-08T07:22:46 Z ogibogi2004 Floppy (RMI20_floppy) C++14
0 / 100
93 ms 12100 KB
#include <stdlib.h>
#include <string.h>
#include<bits/stdc++.h>
#include "floppy.h"
using namespace std;
const int MAXN=4e4+6;

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[st.top()]<v[i])
        {
            st.pop();
            bits+="0";
        }
        bits+="1";
        st.push(i);
    }
    save_to_floppy(bits);
}
int tl[MAXN];
int sp[MAXN][20];
vector<int> solve_queries(int subtask_id, int N,
        const string &bits,
        const vector<int> &a, const vector<int> &b) {
    int i=0;
    stack<int>st;
    vector<int>answers;
    for(int j=0;j<bits.size();j++)
    {
        if(bits[j]==1)
        {
            if(!st.empty())tl[i]=st.top();
            else tl[i]=-1;
            st.push(i);
            i++;
        }
        else
        {
            st.pop();
        }
    }
    for(int i=0;i<N;i++)sp[i][0]=tl[i];
    for(int step=1;step<17;step++)
    {
        for(int i=0;i<N;i++)
        {
            if(sp[i][step-1]==-1)sp[i][step]=-1;
            else sp[i][step]=sp[sp[i][step-1]][step-1];
        }
    }
    for(int i=0;i<b.size();i++)
    {
        int r=b[i];
        int l=a[i];
        for(int j=16;j>=0;j--)
        {
            if(sp[r][j]<l)continue;
            r=sp[r][j];
        }
        answers.push_back(r);
    }
    return answers;
}

Compilation message

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     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:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int j=0;j<bits.size();j++)
      |                 ~^~~~~~~~~~~~
floppy.cpp:54:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i=0;i<b.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 Runtime error 2 ms 804 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 24 ms 3468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 93 ms 12100 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -