Problem: 字符迁移
思路:差分数组
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
int n,q;
cin>>n>>q;
vector<int> cf(n+2,0);
string s;
cin>>s;
while(q--){
int l,r,k;
cin>>l>>r>>k;
cf[l]+=k;
cf[l]%=26;
cf[r+1]-=k;
cf[r+1]%=26;
}
int sum = 0;
for(int i=1;i<=n;i++){
sum=(sum+cf[i])%26;
//+26防止负数,如-2%3=-2,+3调到正数1
s[i-1] = 'a'+(sum+s[i-1]-'a'+26)%26;
}
cout <<s<< endl;
return 0;
}