Submission #645919

# Submission time Handle Problem Language Result Execution time Memory
645919 2022-09-28T09:35:53 Z Vanilla Floppy (RMI20_floppy) C++17
28 / 100
743 ms 6412 KB
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string.h>
#include "floppy.h"
using namespace std;
const int l = 14;

string to_bin (int x) {
    string rs = "";
    for (int i = 0; i < l; i++){
        rs = rs + char(!!(x & (1 << i)) + '0');
    }
    return rs;
}

int get (int x, const string& bits) {
    int rs = 0;
    for (int i = x * l; i < l * (x + 1); i++){
        rs+=((1 << (i - x * l)) * (bits[i] - '0'));
    }
    return rs;
}

void read_array(int subtask_id, const vector<int> &v) {
    vector <int> s;
    for (int i: v) s.push_back(i);
    sort(s.begin(), s.end());
    string bits = "";
    for (int i: v) {
        int k = (lower_bound(s.begin(), s.end(), i) - s.begin());
        // cerr << k << " " << to_bin(k) << "\n";
        bits+=to_bin(k);
    }
    // cerr << get(0, bits) << "\n";
    save_to_floppy(bits);
}

vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) {
    int m = a.size();
    vector <int> ans (m);
    for (int q = 0; q < m; q++){
        int mx = -1, mxpos = 0;
        for (int i = a[q]; i <= b[q]; i++){
            // cerr << q << " " << i << "\n";
            if (get(i, bits) > mx) {
                mx = get(i, bits);
                mxpos = i;
            }
        } 
        ans[q] = mxpos;
    }
    return ans;
}

Compilation message

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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 652 KB Output is correct
2 Correct 4 ms 648 KB Output is correct
3 Correct 5 ms 684 KB Output is correct
4 Correct 4 ms 684 KB Output is correct
5 Correct 4 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 403 ms 3928 KB Output is correct
2 Correct 393 ms 3992 KB Output is correct
3 Correct 743 ms 3924 KB Output is correct
4 Correct 588 ms 3916 KB Output is correct
5 Correct 379 ms 3944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 6412 KB L is too large
2 Halted 0 ms 0 KB -