-
Notifications
You must be signed in to change notification settings - Fork 0
/
B. Dorms War.cpp
82 lines (72 loc) · 1.38 KB
/
B. Dorms War.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t--) {
int n;
cin >> n;
string s;
cin >> s;
int k;
cin >> k;
int m[26];
for(int i = 0; i < 26; i++) {
m[i] = 0;
}
char x;
for(int i = 0; i < k; i++) {
cin >> x;
m[x - 'a'] = 1;
}
int count = 0;
int ans = 0;
for(int i = 0; i < n; i++) {
if(m[s[i] - 'a'] != 0) {
ans = max(ans, count);
count = 1;
} else {
count++;
}
}
cout << ans << "\n";
// nkjks,owow
}
}
/*
#include<bits/stdc++.h>
#define endl "\n"
#define M 1000000007
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--){
int n;
cin >> n;
string a;
cin >> a;
int k;
cin >> k;
int inx[130] = {0}, i;
char ch;
for(i = 0; i < k; i++){
cin >> ch;
inx[ch]++;
}
int c = 0, mx = 0;
for(i = 0; i < n; i++){
if(inx[a[i]] > 0) {
if(c > mx) mx = c;
c = 0;
}
c++;
}
cout<<mx;
cout<<endl;
}
}
*/