Submission #645919

#TimeUsernameProblemLanguageResultExecution timeMemory
645919VanillaFloppy (RMI20_floppy)C++17
28 / 100
743 ms6412 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...