-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathtest1.cpp
More file actions
48 lines (36 loc) · 769 Bytes
/
test1.cpp
File metadata and controls
48 lines (36 loc) · 769 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
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
int main()
{
int h, w;
cin >> h >> w;
int m;
cin >> m;
map<double, set<double>> lines;
for(int i = 0; i < m; i++){
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
double k, b;
if (x1 == x2) {
k = 99999999999999999;
} else {
k = static_cast<double>(y2 - y1) / (x2 - x1);
}
b = y1 - k * x1;
// 存在
auto p = lines.find(k);
if(p != lines.end()){
// 插入到集合
p->second.insert(b);
}
else{
lines[k] = {b};
}
}
cout << ans << endl;
return 0;
}