This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2010, TopCoder, Inc. All rights reserved.
文字列が与えられて,開始位置$position$とその長さ$length$が与えられる.与えらた順番通りに,$[position[[i], position[i] + lenght[i])$を反転したものをその後にくっつける.
$$
[0, pos[i] + len[i]) + reverce[pos[i], pos[i] + len[i]) + [pos[i] + len[i], sz]
$$
する.$sz$はその文字列の長さ
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
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define mp make_pair
using namespace std ;
typedef long long ll ;
typedef pair < int , int > P ;
class PalindromeDecoding {
public :
string decode ( string code , vector < int > position , vector < int > length ) {
int m = position . size ();
rep ( i , m ) {
string a = code . substr ( 0 , position [ i ]);
string b = code . substr ( position [ i ], length [ i ]);
string c = code . substr ( position [ i ] + length [ i ]);
string d = b ;
reverse ( d . begin (), d . end ());
code = a + b + d + c ;
}
return code ;
}
};