CSES - E4590 2016 1 - Results
Submission details
Task:Reversals
Sender:aianevsk
Submission time:2016-09-17 14:14:53 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2--details

Code

#include <iostream>
#include <string>
#include <algorithm>    

int main()
{
  using namespace std;
  ios::sync_with_stdio(false);


  int n,m,a,b; string az;
  cin >> n >> m >> az;  


for (int i = 0; i<m; i++)
{
    //std::istringstream iss(az);
    cin >> a >> b;
    a -= 1; b-=1;
    for (int k = a, j = b; k < j; k++, j--)
    {
     //   c = az[k];
      //  az[k] = az[j];
      //  az[j] = c;
swap(az[k], az[j]);
    }
    

    //tmp = az[a-1];
    //az[a-1] = az[b-1];
    //az[b-1] = tmp;
     //cout << az << "\n";

}	
  cout << az;


return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
50 100
pplcmurzajsxlqqcrxewfhzqyihkzp...

correct output
fpuwlmatkzbhksppmjxpwurcvsdxcz...

user output
fpuwlmatkzbhksppmjxpwurcvsdxcz...

Test 2

Verdict:

input
500000 100000
slsmyuezdrenskmgkwxpcfzistssmu...

correct output
slsmyuezvdfzhssyoofpsnsagrrzri...

user output
(empty)