Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. const int ALP = 26;
  5. const int MAX_N = 100005;
  6.  
  7. int W[ALP][MAX_N];
  8.  
  9. // 0 -> a
  10. // 1 -> b
  11. // 2 -> c
  12. // ..
  13.  
  14. int main() {
  15.     string S;
  16.     cin >> S;
  17.     int n = S.length();
  18.     S = "%" + S;
  19.     for(int i = 1; i <= n; i++) {
  20.         char l = S[i];
  21.         W[l - 'a'][i] = 1;
  22.     }
  23.     for(int l = 0; l < ALP; l++) {
  24.         for(int i = 1; i <= n; i++) {
  25.             W[l][i] += W[l][i - 1];
  26.         }
  27.     }
  28.    
  29.     int zap;
  30.     cin >> zap;
  31.     while(zap--) {
  32.         int x, y;
  33.         char l;
  34.         cin >> x >> y >> l;
  35.         int nr = l - 'a';
  36.         int wys = W[nr][y] - W[nr][x - 1];
  37.         if(wys > 0) {
  38.             cout << "TAK\n";
  39.         } else {
  40.             cout << "NIE\n";
  41.         }
  42.     }
  43.    
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement