Submission #401506

#TimeUsernameProblemLanguageResultExecution timeMemory
401506BertedFloppy (RMI20_floppy)C++14
100 / 100
115 ms13020 KiB
#include <stdlib.h> #include <string.h> #include <algorithm> #include <iostream> #include "floppy.h" #define pii pair<int, int> #define ppi pair<pii, int> #define fst first #define snd second using namespace std; void read_array(int subtask_id, const vector<int> &v) { vector<int> S; string ret = ""; for (const auto &u : v) { while (S.size() && S.back() <= u) {S.pop_back(); ret.push_back('0');} S.push_back(u); ret.push_back('1'); } save_to_floppy(ret); } vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) { //cerr << "S: " << bits << "\n"; vector<int> ret(a.size(), 0), S; vector<ppi> qry; for (int i = 0; i < a.size(); i++) qry.push_back({{b[i], a[i]}, i}); sort(qry.begin(), qry.end()); int j = 0, k = 0; for (const auto &u : qry) { for (; j <= u.fst.fst; j++) { for (; k < bits.size() && bits[k] == '0'; k++) {S.pop_back();} S.push_back(j); k++; } ret[u.snd] = *lower_bound(S.begin(), S.end(), u.fst.snd); //cerr << u.snd << " " << ret[u.snd] << "\n"; } return ret; }

Compilation message (stderr)

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::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = 0; i < a.size(); i++) qry.push_back({{b[i], a[i]}, i});
      |                     ~~^~~~~~~~~~
floppy.cpp:39:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |    for (; k < bits.size() && bits[k] == '0'; k++) {S.pop_back();}
      |           ~~^~~~~~~~~~~~~
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...