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

Code

#include <algorithm>
#include <iostream>
#include <string>
int main(){
	using namespace std;
	ios::sync_with_stdio(0);

	int n, m;
	cin >> n >> m;

	string word = "";

	getline(cin, word); //consume newline
	getline(cin, word);

	for(;m>0; m--){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		while(a < b){
			char temp = word[a];
			word[a] = word[b];
			word[b] = temp;
			a++;
			b--;
		}
	}
	cout << word << "\n";
	
}

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)