# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
894500 | zeta7532 | Collider (IZhO11_collider) | C++17 | 73 ms | 3592 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
const ll sq=1000;
int main() {
ll N,M;
cin >> N >> M;
string s;
cin >> s;
ll cnt=(N+sq-1)/sq;
vector<string> t(cnt);
rep(i,M){
if(i%sq==0){
if(i>0){
s.clear();
rep(j,cnt) s+=t[j],t[j].clear();
}
rep(j,N) t[j/sq]+=s[j];
}
char c;
cin >> c;
if(c=='a'){
ll x,y;
cin >> x >> y;
x--,y--;
char p;
rep(j,cnt){
if(x<t[j].size()){
p=t[j][x];
t[j].erase(t[j].begin()+x);
break;
}
x-=t[j].size();
}
rep(j,cnt){
if(y<=t[j].size()){
t[j].insert(t[j].begin()+y,p);
break;
}
y-=t[j].size();
}
}
if(c=='q'){
ll x;
cin >> x;
x--;
rep(j,cnt){
if(x<t[j].size()){
cout << t[j][x] << endl;
break;
}
x-=t[j].size();
}
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |