Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- const int ALP = 26;
- const int MAX_N = 100005;
- int W[ALP][MAX_N];
- // 0 -> a
- // 1 -> b
- // 2 -> c
- // ..
- int main() {
- string S;
- cin >> S;
- int n = S.length();
- S = "%" + S;
- for(int i = 1; i <= n; i++) {
- char l = S[i];
- W[l - 'a'][i] = 1;
- }
- for(int l = 0; l < ALP; l++) {
- for(int i = 1; i <= n; i++) {
- W[l][i] += W[l][i - 1];
- }
- }
- int zap;
- cin >> zap;
- while(zap--) {
- int x, y;
- char l;
- cin >> x >> y >> l;
- int nr = l - 'a';
- int wys = W[nr][y] - W[nr][x - 1];
- if(wys > 0) {
- cout << "TAK\n";
- } else {
- cout << "NIE\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement