-
Notifications
You must be signed in to change notification settings - Fork 0
/
HOMO.cpp
63 lines (59 loc) · 878 Bytes
/
HOMO.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
#include <bits/stdc++.h>
using namespace std;
map <long long int,long long int> hsh;
int main()
{
long long int t,i,j,num,ctn=0,ctu=0;
string s;
cin>>t;
while(t--)
{
cin>>s>>num;
if(s=="insert")
{
if(hsh[num]==0)
{
ctu++;
}
ctn++;
hsh[num]++;
}
else
{
if(hsh[num]!=0)
{
if(hsh[num]==1)
{
ctu--;
}
ctn--;
hsh[num]--;
}
}
int homo=0,hetro=0;
if(ctu>=2)
{
hetro=1;
}
if(ctu<ctn)
{
homo=1;
}
if(homo==1 && hetro==1)
{
cout<<"both"<<endl;
}
else if(homo==0 && hetro==1)
{
cout<<"hetero"<<endl;
}
else if(homo==1 && hetro==0)
{
cout<<"homo"<<endl;
}
else if(homo==0 && hetro==0)
{
cout<<"neither"<<endl;
}
}
}