CSES - E4590 2016 1 - Results
Submission details
Task:Reversals
Sender:MacAnton
Submission time:2016-09-17 15:01:21 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2--details

Code

#include <iostream>
#include <string>
#include <stdio.h>

int main() {
   using namespace std;
   int n = 0;
   int m = 0;
   cin >> n >> m;

   string ln;
   getline(cin, ln);
   getline(cin, ln);

   for (int i = 0; i < m; i++) {
      int a; int b;
      cin >> a >> b;
      a--; b--;

      char tmp = ' ';
      for (int j = a; j <= (b + a)/2; j++) {
         tmp = ln[j];
         ln[j] = ln[b - (j - a)];
         ln[b - (j - a)] = tmp;
      }
   }

   cout << ln << endl;
   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)