답안 #584731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
584731 2022-06-27T23:32:25 Z Deepesson Floppy (RMI20_floppy) C++17
0 / 100
99 ms 22268 KB
///Encoder
#include <bits/stdc++.h>

void save_to_floppy(const std::string &bits);

#include "floppy.h"

void read_array(int subtask_id, const std::vector<int> &v) {
    std::string answer;
    std::stack<int> stk;
    for(int i=0;i!=v.size();++i){
        auto x = v[i];
        while(stk.size()&&x>=stk.top()){
            answer+="0";
            stk.pop();
        }
        answer+="1";
        stk.push(v[i]);
    }
    save_to_floppy(answer);
}

///Solver
#include <bits/stdc++.h>

#define MAX 205000
typedef std::pair<int,int> pii;

std::vector<pii> queries[MAX];

std::vector<int> solve_queries(int subtask_id, int N,
        const std::string &bits,
        const std::vector<int> &a, const std::vector<int> &b) {
  //  printf("indo\n");
    std::cout<<bits<<"\n";
    std::vector<int> answers;
    for(int i=0;i!=a.size();++i)answers.push_back(-1);
    for(int i=0;i!=a.size();++i){
        queries[b[i]].push_back({a[i],i});
    }
    int cur=0;
    std::vector<pii> stack;
    for(int i=0;i!=N;++i){
        int min=i;
        while(bits[cur]!='1'){
            min=std::min(min,stack.back().second);
            ++cur;
            stack.pop_back();
        }
        stack.push_back({i,min});
        ++cur;
        for(auto&x:queries[i]){
            int la=0,ra=stack.size()-1;
            while(la<ra){
                int m = (la+ra)/2;
                if(stack[m].second<x.first){
                    la=m+1;
                }else ra=m;
            }
            if(la&&stack[la].second>x.first)--la;
           // std::cout<<"Query "<<x.first<<" "<<i<<" "<<x.second<<" "<<stack[la].first<<"\n";
            answers[x.second]=stack[la].first;
        }
    }
   // printf("tada\n");
    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:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0;i!=a.size();++i)answers.push_back(-1);
      |                 ~^~~~~~~~~~
floppy.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 10292 KB Security error -- do not print anything to stdout
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 13120 KB Security error -- do not print anything to stdout
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 99 ms 22268 KB Security error -- do not print anything to stdout
2 Halted 0 ms 0 KB -