Submission #895302

#TimeUsernameProblemLanguageResultExecution timeMemory
895302preskoCollider (IZhO11_collider)C++14
0 / 100
0 ms348 KiB
#include<iostream> #include<bits/stdc++.h> #define MAXN 1000010 using namespace std; int ind[MAXN]; vector<pair<int,int>> order; string s; char getans(int pos) { //int ans=pos; for(int i=0;i<order.size();i++) { int l=order[i].first; int r=order[i].second; if(l<=pos && pos<=r) { order[i]={0,0};//could use -erase- /*if(r-l+1>1) { order.push_back({l,max(pos-1,l)}); order.push_back({min(pos+1,r),r}); } ans++;*/ for(int j=l;j<=r;j++) { ind[j-1]=ind[j]; } ind[r]=l-1; } else if(r<=pos && pos<=l) { order[i]={0,0}; for(int j=l;j>=r;j--) { ind[j+1]=ind[j]; } ind[r]=l+1; } } return s[ind[pos]-1]; } int main() { int n,q; ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>q; cin>>s; for(int i=0;i<s.size();i++) { ind[i+1]=i+1; }//could be skipped for(int i=0;i<q;i++) { char t; cin>>t; if(t=='a') { int ql,qr; cin>>ql>>qr; if(ql+1<=qr)order.push_back({ql+1,qr}); else if(qr<=ql-1)order.push_back({ql-1,qr}); } else { int pos; cin>>pos; cout<<getans(pos)<<"\n"; } } }

Compilation message (stderr)

collider.cpp: In function 'char getans(int)':
collider.cpp:11:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i=0;i<order.size();i++)
      |                 ~^~~~~~~~~~~~~
collider.cpp: In function 'int main()':
collider.cpp:49:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...