Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const ll INF=1000000000000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

string S;
int add[100010];
vector<P> vec[50002];
bool solve(int k,int a,int b){
	//cout << k << " " << a << " " << b << endl;
	if(S.size()-1-k <= k)return true;
	a += add[k]%26;
	b += add[S.size()-1-k]%26;
	int A = a+(S[k]-'a'); A %= 26; S[k] = 'a'+A;
	int B = b+(S[S.size()-1-k]-'a'); B %= 26; S[S.size()-1-k] = 'a'+B;
	if(vec[k].size() == 0){
		if(S[k] != S[S.size()-1-k]){
			return false;
		}
		return solve(k+1,a,b);
	}
	vector<P> _vec;
	rep(i,vec[k].size()){
		if(vec[k][i].fr == k && vec[k][i].sc == S.size()-1-k){}
		else _vec.pb(vec[k][i]);
	}
	vec = _vec;
	sor(vec[k]);
	uniq(vec[k]);
	if(vec[k][0].fr == k){
		for(int i = 1 ; i < vec[k].size() ; i ++){
			if(vec[k][i].fr == k){
				P p = P(vec[k][0].sc,vec[k][i].sc);
				if(p.sc == p.fr)continue;
				if(p.sc < p.fr)swap(p.fr,p.sc);
				p.fr ++;
				vec[min(p.fr,(int)(S.size())-1-p.sc)].pb(p);
			}
			else {
				P p = P(vec[k][0].sc,vec[k][i].fr);
				if(p.fr < p.sc){
					p.fr ++;
					p.sc --;
					if(p.fr > p.sc)continue;
				}
				else swap(p.fr,p.sc);
				vec[min(p.fr,(int)(S.size())-1-p.sc)].pb(p);
			}
		}
		int d = 26-S[k]+S[S.size()-1-k]; d%=26;
		a += d;
//S[k] += d;
//if(S[k] > 'z')S[k] -= 26;
		if(vec[k][0].sc < S.size()/2){
			if(vec[k][0].sc+1 < S.size()/2){
				add[vec[k][0].sc+1] += (26-d)%26;
			}
		}
		else add[vec[k][0].sc] +=d ;
	}
	else {
		for(int i = 1 ; i < vec[k].size() ; i ++){
			if(vec[k][i].fr == k){
				P p = P(vec[k][i].sc,vec[k][0].fr);
				if(p.fr < p.sc){
					p.fr ++;
					p.sc --;
					if(p.fr > p.sc)continue;
				}
				else swap(p.fr,p.sc);
				vec[min(p.fr,(int)(S.size())-1-p.sc)].pb(p);
			}
			else {
				P p = P(vec[k][0].fr,vec[k][i].fr);
				if(p.sc == p.fr)continue;
				if(p.sc < p.fr)swap(p.fr,p.sc);
				p.sc --;
				vec[min(p.fr,(int)(S.size())-1-p.sc)].pb(p);
			}
		}
		int d = 26+S[k]-S[S.size()-1-k]; d%=26;
		b += d;
//S[S.size()-1-k] += d;
//if(S[S.size()-1-k] > 'z')S[S.size()-1-k] -= 26;
		if(vec[k][0].fr < S.size()/2)add[vec[k][0].fr] += d;
		else{
			if(vec[k][0].fr-1 > S.size()/2){
				add[vec[k][0].fr-1] += 26-d ;
			}
		}
	}
	return solve(k+1,a,b);
}


int main(){
	static int n;
	static int l[100010],r[100010];
	cin >> S;
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&l[i],&r[i]);
		l[i] --;
		r[i] --;
		if(l[i] > r[i])swap(l[i],r[i]);
		vec[min(l[i],(int)(S.size())-1-r[i])].pb(P(l[i],r[i]));
	}
	if(solve(0,0,0))puts("YES");
	else puts("NO");
	
	//cout << S << endl;
}
	



Compiler output:
a.cc: In function 'bool solve(int, int, int)':
a.cc:58:13: error: incompatible types in assignment of 'std::vector<std::pair<long long int, long long int> >' to 'std::vector<std::pair<long long int, long long int> > [50002]'
   58 |         vec = _vec;
      |         ~~~~^~~~~~