Submission #493440

#TimeUsernameProblemLanguageResultExecution timeMemory
493440Jeff12345121Floppy (RMI20_floppy)C++14
7 / 100
41 ms7664 KiB
#include <stdlib.h> #include <string.h> #include <bits/stdc++.h> using namespace std; #include "floppy.h" const int MAXBIT = 30; /*string gbits; void save_to_floppy(const string &bits) { gbits = bits; }*/ string makeBin(int x) { string bin = ""; for (int i = 0; i <= MAXBIT; i++) { bin += ( ( x & ( 1 << i ) ) ? '1' : '0' ); } return bin; } void read_array(int subtask_id, const std::vector<int> &v) { string bits = ""; vector<pair<int,int>> norm(v.size()); for (int i = 0; i < v.size(); i++) norm[i] = {v[i] , i}; sort(norm.begin() , norm.end()); vector<int> place(v.size()); for (int i = 0; i < norm.size(); i++) { place[norm[i].second] = i; } for (int i = 0; i < v.size(); i++) { bits += makeBin(place[i]); } 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) { vector<int> place(N); int pos = 0; for (int i = 0; i < bits.size();) { for (int bit = 0; bit <= 30; bit++) { if (bits[i] == '1') { place[pos] += (1 << bit); } i++; } pos++; } vector<int> answers; for (int i = 0; i < a.size(); i++) { int maxInd = a[i]; for (int j = a[i] + 1; j <= b[i]; j++) { if (place[j] > place[maxInd]) { maxInd = j; } } answers.push_back(maxInd); } return answers; } /* int main() { read_array(1 , {4 , 2 , 3 , 7 , 1 , 5 , 6, 8}); solve_queries(1 , 8 , gbits , {2,2} , {4,7}); }*/

Compilation message (stderr)

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = 0; i < v.size(); i++) norm[i] = {v[i] , i};
      |                     ~~^~~~~~~~~~
floppy.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < norm.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
floppy.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     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:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i = 0; i < bits.size();) {
      |                     ~~^~~~~~~~~~~~~
floppy.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...