Task: | Reversals |
Sender: | omantere |
Submission time: | 2016-09-17 15:22:16 +0300 |
Language: | C++ |
Status: | READY |
Result: | TIME LIMIT EXCEEDED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | TIME LIMIT EXCEEDED | -- | details |
Code
#include <bits/stdc++.h> using namespace std; void rev(string& str, int a, int b) { int swaps = (int)floor((b-a+1)/2); for(int i = 0; i < swaps; i++) { swap(str[a+i], str[b-i]); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; int n, m; cin >> n; cin >> m; cin >> s; for(int i = 0; i < m; i++) { int a, b; cin >> a; cin >> b; a--; b--; rev(s, a, b); } cout << s << endl; return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
50 100 pplcmurzajsxlqqcrxewfhzqyihkzp... |
correct output |
---|
fpuwlmatkzbhksppmjxpwurcvsdxcz... |
user output |
---|
fpuwlmatkzbhksppmjxpwurcvsdxcz... |
Test 2
Verdict: TIME LIMIT EXCEEDED
input |
---|
500000 100000 slsmyuezdrenskmgkwxpcfzistssmu... |
correct output |
---|
slsmyuezvdfzhssyoofpsnsagrrzri... |
user output |
---|
(empty) |