Submission #967128

#TimeUsernameProblemLanguageResultExecution timeMemory
967128AtabayRajabliFloppy (RMI20_floppy)C++17
0 / 100
27 ms6588 KiB
#include <bits/stdc++.h> using namespace std; #include "floppy.h" string bin(int x) { string res = ""; bool ng = x < 0; if(ng)x *= -1; for(int i = 0; i < 20; i++) { if((1 << i) & x) res += '1'; else res += '0'; } if(ng)res += '1'; reverse(res.begin(), res.end()); return res; } void read_array(int subtask_id, const vector<int> &v) { string bits = ""; for(int i = 0; i < v.size(); i++) { bits += bin(v[i]); } save_to_floppy(bits); } vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) { vector<int> ans; vector<int> v; for(int i = 20; i < bits.size(); i += 21) { int j = i, x = 0; while(j > 0) { x += (bits[j] == '1') * (1 << (i - j)); j--; } if(bits[j] == '1')x *= -1; v.push_back(x); } for(int i = 0; i < a.size(); i++) { ans.push_back(*max_element(v.begin() + a[i], v.begin() + b[i])); } return ans; }

Compilation message (stderr)

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     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:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i = 20; i < bits.size(); i += 21)
      |                     ~~^~~~~~~~~~~~~
floppy.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     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...