0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 21:28:48 +00:00

B - Irreducible Anagrams

https://codeforces.com/contest/1290/submission/177710968
This commit is contained in:
Baoshuo Ren 2022-10-24 10:37:45 +08:00
parent 3861d005e4
commit b94989caf0
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

48
Codeforces/1290/B/B.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <iostream>
#include <algorithm>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e5 + 5;
int n, a[N][26];
std::string s;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> s >> n;
s = ' ' + s;
for (int i = 1; i < s.size(); i++) {
std::copy_n(a[i - 1], 26, a[i]);
a[i][s[i] - 'a']++;
}
for (int i = 1, l, r; i <= n; i++) {
cin >> l >> r;
if (s[l] != s[r] || l == r) {
cout << "Yes" << endl;
continue;
}
int cnt = 0;
for (int i = 0; i < 26; i++) {
if (a[r][i] - a[l - 1][i] > 0) {
cnt++;
}
}
cout << (cnt < 3 ? "No" : "Yes") << endl;
}
return 0;
}