Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct Q {
- char type;
- int val;
- };
- int main() {
- int n;
- scanf("%d", &n);
- vector<int> comp(n);
- vector<Q> q(n);
- char buf[10];
- for(int i = 0; i < n; ++i) {
- int x;
- scanf("%s%d", buf, &x);
- comp[i] = x;
- q[i] = {buf[0], x};
- }
- sort(comp.begin(), comp.end());
- vector<int> cnt(n);
- int neq = 0, ndif = 0;
- for(int i = 0; i < n; ++i) {
- int idx = lower_bound(comp.begin(), comp.end(), q[i].val) - comp.begin();
- if(q[i].type == 'i') {
- int z = ++cnt[idx];
- if(z == 2) {
- ++neq;
- }
- if(z == 1) {
- ++ndif;
- }
- } else {
- if(cnt[idx]) {
- int z = --cnt[idx];
- if(z == 1) {
- --neq;
- }
- if(!z) {
- --ndif;
- }
- }
- }
- if(neq) {
- puts(ndif >= 2 ? "both" : "homo");
- } else {
- puts(ndif >= 2 ? "hetero" : "neither");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement