mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
B - Irreducible Anagrams
https://codeforces.com/contest/1290/submission/177710968
This commit is contained in:
parent
3861d005e4
commit
b94989caf0
48
Codeforces/1290/B/B.cpp
Normal file
48
Codeforces/1290/B/B.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user