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>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F(i,a,b) for(ll i=a;i<=b;i++)
const ll mxn=2e5+5;
ll k,m,n;
string s;
ll a[mxn],b[mxn],c[mxn];
char solve(ll pos,ll x)
{
    if (x==0)
    {
        return s[pos];
    }
    ll len=b[x]-a[x];
    if (pos<c[x])
    {
        return solve(pos,x-1);
    }
    else if (pos<c[x]+len)
    {
        return solve(a[x]+pos-c[x],x-1);
    }
    else
    {
        return solve(pos-len,x-1);
    }
}
int main()
{
    //freopen("nah.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>k>>m;
    cin>>s;
    cin>>n;
    F(i,1,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    F(i,0,k-1)
    {
        cout<<solve(i,n);
    }
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |