Submission #471162

#TimeUsernameProblemLanguageResultExecution timeMemory
471162mosiashvililukaFloppy (RMI20_floppy)C++14
100 / 100
120 ms12684 KiB
#include<bits/stdc++.h> #include "floppy.h" using namespace std; int a,b,c,d,e,i,j,ii,jj,zx,xc,f[200009],pi,lef,rig,mid; pair <pair <int, int>, int> p[200009]; vector <int> ans; deque <int> de; string s; void read_array(int subtask_id, const std::vector<int> &v) { a=v.size(); for(i=1; i<=a; i++){ f[i]=v[i-1]; } while(de.size()) de.pop_back(); for(i=1; i<=a; i++){ while(de.size()&&f[de.back()]<f[i]){ de.pop_back();s+="1"; } de.push_back(i);s+="0"; } //cout<<s<<endl; save_to_floppy(s); } vector<int> solve_queries(int subtask_id, int N, const std::string &bits, const std::vector<int> &A, const std::vector<int> &B) { while(de.size()) de.pop_back(); a=N;ans.resize(A.size()); for(i=0; i<A.size(); i++){ pi++;p[pi].first.second=A[i]+1;p[pi].first.first=B[i]+1;p[pi].second=i; } sort(p+1,p+pi+1); for(i=1; i<=pi; i++) swap(p[i].first.first,p[i].first.second); j=0;ii=1; for(i=1; i<=pi; i++){ for(jj=ii; jj<=p[i].first.second; jj++){ while(1){ if(bits[j]=='0') break; de.pop_back(); j++; } de.push_back(jj);j++; } ii=jj; lef=-1;rig=de.size(); while(1){ if(lef+1>=rig) break; mid=(lef+rig)/2; if(de[mid]>=p[i].first.first){ rig=mid; }else{ lef=mid; } } //cout<<de.size()<<" "<<rig<<endl; ans[p[i].second]=de[rig]-1; } return ans; }

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:31:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(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...