Submission #876474

# Submission time Handle Problem Language Result Execution time Memory
876474 2023-11-21T19:25:07 Z MinaRagy06 Floppy (RMI20_floppy) C++17
28 / 100
27 ms 6580 KB
#include <bits/stdc++.h>
#include "floppy.h"
#ifdef MINA
#include "grader.cpp"
#endif
using namespace std;
#define ll long long

void read_array(int sub, const vector<int> &v) {
	vector<int> vals;
	for (auto i : v) {
		vals.push_back(i);
	}
	sort(vals.begin(), vals.end());
	string s;
	int cnt = __lg(v.size() - 1) + 1;
	for (auto i : v) {
		int x = lower_bound(vals.begin(), vals.end(), i) - vals.begin();
		for (int j = 0; j < cnt; j++) {
			s.push_back(((x >> j) & 1) + '0');
		}
	}
	save_to_floppy(s);
}
vector<int> solve_queries(int sub, int n, const string &bits, const vector<int> &a, const vector<int> &b) {
	pair<int, int> sparse[16][n];
	for (int j = 0; j < 16; j++) {
		for (int i = 0; i < n; i++) {
			sparse[j][i] = {0, -1};
		}
	}
	int cnt = __lg(n - 1) + 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < cnt; j++) {
			if (bits[cnt * i + j] == '1') {
				sparse[0][i].first |= 1 << j;
			}
		}
		sparse[0][i].second = i;
	}
	for (int j = 1; j < 16; j++) {
		for (int i = 0; i + (1 << (j - 1)) < n; i++) {
			sparse[j][i] = max(sparse[j - 1][i], sparse[j - 1][i + (1 << (j - 1))]);
		}
	}
	int q = a.size();
	vector<int> ans(q);
	for (int i = 0; i < q; i++) {
		int lg = __lg(b[i] - a[i] + 1);
		ans[i] = max(sparse[lg][a[i]], sparse[lg][b[i] - (1 << lg) + 1]).second;
	}
	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 2 ms 824 KB Output is correct
2 Correct 1 ms 832 KB Output is correct
3 Correct 2 ms 824 KB Output is correct
4 Correct 1 ms 824 KB Output is correct
5 Correct 1 ms 1340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 5376 KB Output is correct
2 Correct 24 ms 5368 KB Output is correct
3 Correct 24 ms 5364 KB Output is correct
4 Correct 25 ms 5372 KB Output is correct
5 Correct 25 ms 5372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 6580 KB L is too large
2 Halted 0 ms 0 KB -