Submission #859660

#TimeUsernameProblemLanguageResultExecution timeMemory
859660nguyentunglamFloppy (RMI20_floppy)C++17
100 / 100
76 ms17676 KiB
#include <stdlib.h> #include <string.h> #include "floppy.h" #include<bits/stdc++.h> using namespace std; void read_array(int subtask_id, const std::vector<int> &v) { string ret; vector<int> st; for(int i = 0; i < v.size(); i++) { while (!st.empty() && v[i] > v[st.back()]) { ret.push_back('1'); st.pop_back(); } ret.push_back('0'); st.push_back(i); } save_to_floppy(ret); } const int M = 1e5 + 10; vector<pair<int, int> > query[M]; std::vector<int> solve_queries(int subtask_id, int N, const std::string &bits, const std::vector<int> &a, const std::vector<int> &b) { std::vector<int> ans(a.size()); for(int i = 0; i < a.size(); i++) query[b[i]].emplace_back(a[i], i); int j = 0; vector<int> st; for(int i = 0; i < N; i++) { int cnt = 0; while (bits[j] == '1') { j++; st.pop_back(); } j++; st.push_back(i); for(auto &[l, idx] : query[i]) { ans[idx] = *lower_bound(st.begin(), st.end(), l); // ans[idx] = 1; } } return ans; }

Compilation message (stderr)

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:11:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |    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:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0; i < a.size(); i++) query[b[i]].emplace_back(a[i], i);
      |                    ~~^~~~~~~~~~
floppy.cpp:37:11: warning: unused variable 'cnt' [-Wunused-variable]
   37 |       int cnt = 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...