Submission #923886

#TimeUsernameProblemLanguageResultExecution timeMemory
923886vjudge1Floppy (RMI20_floppy)C++17
100 / 100
77 ms21820 KiB
#include <bits/stdc++.h> #include "floppy.h" using namespace std; void read_array(int subtask_id, const std::vector<int> &v) { string res = ""; stack<int> t; for (int i = 0; i < v.size(); i++) { while (!t.empty() && t.top() <= v[i]) { res += '0'; t.pop(); } t.push(v[i]); res += '1'; } save_to_floppy(res); } vector<int> g[200005]; std::vector<int> solve_queries(int subtask_id, int N, const std::string &bits, const std::vector<int> &a, const std::vector<int> &b) { int n = bits.size(), q = a.size(), c = 0; vector<int> v, res(q); for (int i = 0; i < q; i++) { g[b[i]].push_back(i); } for (int i = 0; i < N; i++) { while (bits[c] == '0') { v.pop_back(); c++; } v.push_back(i); for (int j = 0; j < g[i].size(); j++) { res[g[i][j]] = *lower_bound(v.begin(), v.end(), a[g[i][j]]); } c++; } return res; }

Compilation message (stderr)

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:7:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     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:30:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int j = 0; j < g[i].size(); j++) {
      |                         ~~^~~~~~~~~~~~~
floppy.cpp:19:9: warning: unused variable 'n' [-Wunused-variable]
   19 |     int n = bits.size(), q = a.size(), c = 0;
      |         ^
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...