-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGang_War.cpp
63 lines (60 loc) · 1.24 KB
/
Gang_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
#include<bits/stdc++.h>
using namespace std;
bool sameAxis(set<int>& ky, int y) {
// cout<<y<<" : ";
// for(int x : ky)
// cout<<x<<" < ";
// cout<<endl;
auto lb = ky.lower_bound(y);
if(lb == ky.end())
return false;
if(*lb > y && lb == ky.begin())
return false;
// cout<<"yes"<<endl;
return true;
}
int Killer(vector<pair<int,int>>& kill, vector<pair<int,int>>& die, int n) {
map<int, set<int>> kx, ky;
int x, y;
for(int i = 0 ; i < n ; i++) {
x = kill[i].first;
y = kill[i].second;
kx[x].insert(y);
ky[y].insert(x);
}
int died = 0;
for(int i = 0 ; i < n ; i++) {
x = die[i].first;
y = die[i].second;
if(sameAxis(kx[x], y)) {
died++;
// cout<<x<<" "<<y<<endl;
}
else if(sameAxis(ky[y], x)) {
died++;
// cout<<x<<" "<<y<<endl;
}
}
return died;
}
int main(void) {
int n;
cin>>n;
vector<pair<int,int>> M(n), L(n);
int x, y;
for(int i = 0 ; i < n ; i++) {
cin>>x>>y;
M[i]=make_pair(x,y);
}
for(int i = 0 ; i < n ; i++) {
cin>>x>>y;
L[i]=make_pair(x,y);
}
int Mkilled = Killer(L, M, n);
int Lkilled = Killer(M, L, n);
int totoalKill = Mkilled + Lkilled;
cout<<totoalKill<<endl;
cout<<"MOOSE "<<Mkilled<<" "<<(n - Mkilled)<<endl;
cout<<"LAWREN "<<Lkilled<<" "<<(n - Lkilled)<<endl;
return 0;
}