aboutsummaryrefslogtreecommitdiff
path: root/DormsRoom.cpp
blob: 028ec8a8d3151adbb33ef3800ca3e27b42e9a17f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<bits/stdc++.h>

using namespace std;

int main() {
  int tt;
  cin >> tt;
  while(tt--) {
    int n; cin >> n;
    string s; cin >> s;
    int sp; cin >> sp;
    map<char, bool> mp;
    for(int i = 0; i < sp; i++) {
      char inn;
      cin >> inn;
      mp[inn] = 1;
    }
    int mx = 0, c = 0;
    for(auto ch : s) {
      if(mp[ch]) {
        mx = max(c, mx);
        c = 1;
      }
      else {
        c++;
      }
    }
    cout << mx << endl;
  }
}