#include<bits/stdc++.h>
#include<ext/rope>
/*
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")*/
#define I inline void
#define S struct
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std ;
using namespace __gnu_cxx ;
using ll = long long ;
using ld = long double ;
const int N = 5e5 + 7 , mod = 1e9 + 7 ;
const int inf = N ;
// How interesting!
int n , m ;
string s ;
int main(){
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
cin >> n >> m;
rope<int> rp (n , 0) ;
cin >> s ;
for(int i = 0 ;i < n;i++){
rp.mutable_reference_at(i) = s[i] - 'a' ;
}
for(int i = 0 ;i < m; i ++){
char a ;
int b , c;
cin >> a ;
if(a == 'a'){
cin >> b >> c ;
b -- ; c-- ;
int x = rp[b] ;
rp.erase(b , 1) ;
rp.insert(c, x );
}else{
cin >> b ;
int x = rp[b-1] ;
cout<< char(x + 'a') <<"\n" ;
}
}
return 0 ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
28 ms |
512 KB |
Output is correct |
3 |
Correct |
44 ms |
4224 KB |
Output is correct |
4 |
Correct |
174 ms |
22924 KB |
Output is correct |
5 |
Correct |
253 ms |
23316 KB |
Output is correct |
6 |
Correct |
312 ms |
25876 KB |
Output is correct |
7 |
Correct |
348 ms |
28440 KB |
Output is correct |
8 |
Correct |
203 ms |
28000 KB |
Output is correct |
9 |
Correct |
386 ms |
28944 KB |
Output is correct |
10 |
Correct |
294 ms |
28820 KB |
Output is correct |