답안 #967128

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
967128 2024-04-21T07:58:24 Z AtabayRajabli Floppy (RMI20_floppy) C++17
0 / 100
27 ms 6588 KB
#include <bits/stdc++.h>
using namespace std;
#include "floppy.h"

string bin(int x)
{
    string res = "";
    bool ng = x < 0;
    if(ng)x *= -1;
    for(int i = 0; i < 20; i++)
    {
        if((1 << i) & x) res += '1';
        else res += '0';
    }
    if(ng)res += '1';
    reverse(res.begin(), res.end());
    return res;
}

void read_array(int subtask_id, const vector<int> &v) {
    string bits = "";
    for(int i = 0; i < v.size(); i++)
    {
        bits += bin(v[i]);
    }
    save_to_floppy(bits);
}

vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) {
    vector<int> ans;
    vector<int> v;
    for(int i = 20; i < bits.size(); i += 21)
    {
        int j = i, x = 0;
        while(j > 0)
        {
            x += (bits[j] == '1') * (1 << (i - j));
            j--;
        }
        if(bits[j] == '1')x *= -1;
        v.push_back(x);
    }
    for(int i = 0; i < a.size(); i++)
    {
        ans.push_back(*max_element(v.begin() + a[i], v.begin() + b[i]));
    }
    return ans;
}

Compilation message

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     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:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i = 20; i < bits.size(); i += 21)
      |                     ~~^~~~~~~~~~~~~
floppy.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     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 4 ms 828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 2212 KB L is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 6588 KB L is too large
2 Halted 0 ms 0 KB -