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

Code

#include <iostream>
#include <string>

int main(void)
{
  std::ios::sync_with_stdio(0);

  int n, m;
  std::string str;
  std::cin >> n >> m >> str;

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

    while (b - a >= 1) {
      char tmp;
      tmp = str[b];
      str[b] = str[a];
      str[a] = tmp;
      a++; b--;
    }
  }

  std::cout << str << std::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)