답안 #494474

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494474 2021-12-15T14:18:23 Z maks007 Floppy (RMI20_floppy) C++14
7 / 100
45 ms 3712 KB
#include <stdlib.h>
#include <string.h>
#include <bits/stdc++.h>

#include "floppy.h"

using namespace std;

void read_array(int subtask_id, const std::vector<int> &v) {
    std::string bits;
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j <= 30; j++) {
            if (v[i] & (1 << j)) bits += "1";
            else bits += "0";
        }
    }
    save_to_floppy(bits);
}

std::vector<int> solve_queries(int subtask_id, int N,
        const std::string &bits,
        const std::vector<int> &a, const std::vector<int> &b) {
    std::vector<int> ans;

    int M = a.size();

    for (int i = 0; i < M; i++) {
        function<pair<int,int>(int, int)> getmax = [&](int l, int r) {
            l *= 31;
            r *= 31;
            int idx = l / 31;
            pair<int, int> ans = {INT_MIN, 0};
            while (l <= r) {
                int p = 1, sum = 0, cnt = 31;
                while (cnt--) {
                    if (bits[l] == '1') sum += p;
                    l++;
                    p <<= 1;
                }
                ans = max(ans, {sum, idx});
                idx++;
            }
            return ans;
        };
        ans.push_back(getmax(a[i], b[i]).second);
    }

    return ans;
}

Compilation message

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:11:23: 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++) {
      |                     ~~^~~~~~~~~~
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 5 ms 740 KB Output is correct
2 Correct 6 ms 752 KB Output is correct
3 Correct 7 ms 772 KB Output is correct
4 Correct 7 ms 784 KB Output is correct
5 Correct 5 ms 816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 1408 KB L is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 3712 KB L is too large
2 Halted 0 ms 0 KB -