-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay5_Part1.cpp
61 lines (56 loc) · 1.26 KB
/
Day5_Part1.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
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
int n=500;
int m=1000;
vector<vector<int>>arr(m, vector<int>(m,0));
for(int i=0;i<n;i++){
string str;
cin>>str;
stringstream ss(str);
vector<int>v;
for (int i; ss >> i;) {
v.push_back(i);
if (ss.peek() == ',')
ss.ignore();
}
cin>>str;
cin>>str;
stringstream ss2(str);
for (int i; ss2 >> i;) {
v.push_back(i);
if (ss2.peek() == ',')
ss2.ignore();
}
if(v[0]>v[2]){
swap(v[0],v[2]);
swap(v[1],v[3]);
}
if(v[0]==v[2] && v[1]>v[3]){
swap(v[1],v[3]);
}
if(v[0]==v[2]){
for(int j=v[1];j<=v[3];j++){
arr[v[0]][j]++;
}
continue;
}
if(v[1]==v[3]){
for(int j=v[0];j<=v[2];j++){
arr[j][v[1]]++;
}
continue;
}
}
int ans=0;
for(int i=0;i<m;i++){
for(int j=0;j<m;j++){
if(arr[i][j]>1){
ans++;
}
}
}
cout<<ans<<endl;
return 0;
}