# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88154 | abil | Collider (IZhO11_collider) | C++14 | 2091 ms | 8848 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
Solution by Abil
**/
#include <bits/stdc++.h>
using namespace std;
main()
{
ios_base::sync_with_stdio(0);
int n, m;
cin >> n >> m;
string s;
cin >> s;
int l, r;
char ch;
string s1,s2,s3;
while(m--){
cin >> ch;
if(ch == 'a'){
cin >> l >> r;
if(l < r){
s1 = s.substr(0,l - 1);
s2 = s.substr(r);
int p = r - l;
s3 = s.substr(l,p);
s3 =s3 + s[l - 1];
s = s1 + s3 + s2;
}
else
if(r < l){
s1 = s.substr(0,r - 1);
s2 = s.substr(l);
int p = l - r;
s3 = s.substr(r - 1,p);
s3 =s[l - 1] + s3;
s = s1 + s3 + s2;
}
}
else{
cin >> l;
cout << s[l - 1] << endl;
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |