AcWing 3723. 字符串查询
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 5e4 + 10;
int A, B, C, D, Q;
unsigned int f[N];
void solve() {
string S;
cin >> S >> Q;
int siz = S.size();
S = "~" + S;
for(int i = 1;i<=siz;i++){
f[i] = f[i-1] + pow(S[i]-'a',2);
}
for (int i = 1; i <= Q; i++) {
cin >> A >> B >> C >> D;
cout << ((f[B]-f[A-1]) == (f[D]-f[C-1]) ? "DA" : "NE") << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}