[Offer收割]编程练习赛42 register

Ended

Participants:125

Verdict:Time Limit Exceeded
Score:50 / 100
Submitted:2017-12-31 13:30:22

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100010
int L[MAX_N], R[MAX_N];
int main() {
    string s;
    int K;
    while (cin >> s) {
        int N = s.size();
        cin >> K;
        for (int i = 0; i < K; i++) {
            cin >> L[i] >> R[i];
        }
        int mid = 0, l, r;
        int d = 1, cur = 0;
        for (int i = 0; i < N; i++) {
            l = L[i], r = R[i];
            mid = (l + r) / 2;
            for (int j = l; j < r; j++) {
                char c = s[j];
                s[j] = s[r];
                s[r] = c;
                r--;
            }
        }
        cout << s << endl;
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX