Submission #475261

#TimeUsernameProblemLanguageResultExecution timeMemory
475261stefantagaFloppy (RMI20_floppy)C++14
28 / 100
1109 ms12712 KiB
#include <stdlib.h> #include <string.h> #include <bits/stdc++.h> #include "floppy.h" using namespace std; int v[40005],n; stack <int> st; void read_array(int subtask_id, const std::vector<int> &x) { std::string bits; n=x.size(); int i; for (i=1;i<=n;i++) { v[i]=x[i-1]; } for (i=1;i<=n;i++) { while (!st.empty()&&v[st.top()]<v[i]) { st.pop(); bits+="1"; } st.push(i); bits+="0"; } save_to_floppy(bits); } int stanga[50005]; vector <pair <int,int> > queryuri; std::vector<int> solve_queries(int subtask_id, int N, const std::string &bits, const std::vector<int> &a, const std::vector<int> &b) { n=N; int i,poz; while (!st.empty())st.pop(); poz=1; for (i=0;i<bits.size();i++) { if (bits[i]=='0') { if (st.empty()) { stanga[poz]=0; } else { stanga[poz]=st.top(); } st.push(poz); poz++; } else { st.pop(); } } for (i=0;i<a.size();i++) { queryuri.push_back({a[i]+1,b[i]+1}); } vector <int> answers; for (i=0;i<queryuri.size();i++) { int minim=1e9,pozitie=0; for (int j=queryuri[i].first;j<=queryuri[i].second;j++) { if (stanga[j]<=minim) { minim=stanga[j]; pozitie=j-1; } } answers.push_back(pozitie); } return answers; }

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:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (i=0;i<bits.size();i++)
      |              ~^~~~~~~~~~~~
floppy.cpp:58:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for (i=0;i<a.size();i++)
      |              ~^~~~~~~~~
floppy.cpp:63:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for (i=0;i<queryuri.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...