#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 |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
178 ms |
10868 KB |
Output is correct |
10 |
Correct |
116 ms |
10840 KB |
Output is correct |
11 |
Correct |
97 ms |
10832 KB |
Output is correct |
12 |
Correct |
180 ms |
10844 KB |
Output is correct |
13 |
Correct |
88 ms |
10748 KB |
Output is correct |
14 |
Correct |
143 ms |
10724 KB |
Output is correct |
15 |
Correct |
84 ms |
10704 KB |
Output is correct |
16 |
Correct |
89 ms |
10772 KB |
Output is correct |
17 |
Correct |
209 ms |
10572 KB |
Output is correct |
18 |
Correct |
56 ms |
10704 KB |
Output is correct |
19 |
Correct |
62 ms |
10764 KB |
Output is correct |
20 |
Correct |
58 ms |
10724 KB |
Output is correct |
21 |
Correct |
65 ms |
10756 KB |
Output is correct |
22 |
Correct |
95 ms |
10800 KB |
Output is correct |
23 |
Correct |
94 ms |
10900 KB |
Output is correct |
24 |
Correct |
100 ms |
10672 KB |
Output is correct |
25 |
Correct |
142 ms |
10804 KB |
Output is correct |
26 |
Correct |
193 ms |
10828 KB |
Output is correct |