-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildingPalidromes.cpp
More file actions
55 lines (51 loc) · 977 Bytes
/
buildingPalidromes.cpp
File metadata and controls
55 lines (51 loc) · 977 Bytes
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
#include<iostream>
#include<string>
using namespace std;
int main()
{
int t;
cin>>t;
for (size_t z = 0; z < t; z++)
{
int block,ques,ans=0;
cin>>block>>ques;
string str;
cin>>str;
//cout<<str;
for (size_t i = 0; i < ques; i++)
{
int hash[26]={0};
int l,r;
cin>>l>>r;
l--;
r--;
for (size_t j = l; j <= r; j++)
{
int temp=str[j]-65;
if(hash[temp]==1)
{
hash[temp]--;
}
else
{
hash[temp]++;
}
//cout<<":"<<temp<<str[j]<<" :"<<hash[temp]<<"\t";
}
int onec=0;
for (size_t j = 0; j < 26; j++)
{
if(hash[j]==1)
{
onec++;
}
}
if(onec<=1)
{
ans++;
}
//cout<<endl;
}
cout<<"Case #"<<z+1<<": "<<ans<<endl;
}
}