답안 #646576

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646576 2022-09-30T07:32:16 Z lis05st Floppy (RMI20_floppy) C++17
8.8394 / 100
190 ms 4912 KB
#include <stdlib.h>
#include <string.h>

#include "floppy.h"
#include<bits/stdc++.h>
using namespace std;


const int BITS=17;
string tostr(int x){
    string res;
    for(int i=BITS-1;i>=0;i--){
        res+='0'+((x>>i)&1);
    }
    return res;
}
int fromstr(string s){
    int res=0;
    for(int i=0;i<BITS;i++){
        res<<=1;
        res+=s[i]-'0';
    }
    return res;
}

void read_array(int subtask_id, const std::vector<int> &v) {
    vector<int>vec;
    map<int,int>mp;
    for(auto e:v)vec.push_back(e);
    sort(vec.begin(),vec.end());
    for(auto e:vec){
        if(mp.count(e))continue;
        mp[e]=mp.size();
    }
    string s;
    for(auto e:v)s+=tostr(mp[e]);
    save_to_floppy(s);
}

std::vector<int> solve_queries(int subtask_id, int N,
        const std::string &bits,
        const std::vector<int> &a, const std::vector<int> &b) {
    vector<int>numbers;
    for(int i=0;i<bits.size();i+=BITS){
        numbers.push_back(fromstr(bits.substr(i,BITS)));
    }
    std::vector<int> answers;
    for(int i=0;i<a.size();i++){
        answers.push_back(max_element(numbers.begin()+a[i],numbers.begin()+b[i]+1)-numbers.begin());
    }
    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:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=0;i<bits.size();i+=BITS){
      |                 ~^~~~~~~~~~~~
floppy.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     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 Correct 2 ms 664 KB Output is correct
2 Correct 3 ms 672 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
4 Correct 2 ms 664 KB Output is correct
5 Correct 3 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 122 ms 3716 KB Partially correct
2 Partially correct 111 ms 3808 KB Partially correct
3 Partially correct 190 ms 3732 KB Partially correct
4 Partially correct 155 ms 3804 KB Partially correct
5 Partially correct 110 ms 3720 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 4912 KB L is too large
2 Halted 0 ms 0 KB -