-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdiff_Main.cpp
More file actions
77 lines (73 loc) · 2.27 KB
/
Copy pathdiff_Main.cpp
File metadata and controls
77 lines (73 loc) · 2.27 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
diff --git a/CodeJam/Main.cpp b/examples/2020/Round2/C/Main.cpp
index 2150379..43d927a 100644
--- a/CodeJam/Main.cpp
+++ b/examples/2020/Round2/C/Main.cpp
@@ -4,7 +4,7 @@
// #define IA_MODE //remove comment on this line, to activate interactive problem mode
#define IA_ERROR_CODE -1
#define IA_COMM_LOG //add comment on this line, to deactivate the interactive communication error log
-// #define XY_NOTATION //remove commment on this line, to activate xy notation on complex numbers
+#define XY_NOTATION //remove commment on this line, to activate xy notation on complex numbers
#define COMM_TYPE ll
// The maintained and empty code template can be found at:
@@ -1570,11 +1570,63 @@ void init(){
cin >> T;
}
+ll N;
+v(cell) holes;
+
void readInput(){
+ cin >> N;
+ holes.cl;
+ forn(i, N){
+ ll t1, t2;
+ cin >> t1 >> t2;
+ holes.pb(cell(t1, t2));
+ }
}
// write to COMM_TYPE result
void calcFunction() {
+ result = N<=2?N:2;
+ d(ll, ll) counts;
+ forn(i, N){
+ fornn(j, i+1, N){
+ counts.cl;
+
+ cell grad=holes[i] - holes[j];
+ if(grad.x < 0 && grad.y < 0){
+ grad *= -1;
+ }
+ if(grad.x * grad.y ==0){
+ grad /= (grad.x + grad.y);
+ } else{
+ ll g = gcd(grad.x, grad.y);
+ grad /= g;
+ }
+ cell ortho_grad(-grad.y, grad.x);
+ llog("cur grad", grad);
+ llog("ortho_grad", ortho_grad);
+ forn(ci, N){
+ ll sp = ortho_grad.x * holes[ci].x + ortho_grad.y * holes[ci].y;
+ // llog("scalar product between", ortho_grad, "and", holes[ci], "is", sp);
+ counts[sp]++;
+ }
+
+ llog("counts");
+ llog(counts);
+
+ ll singles=0;
+ ll odds=0;
+ foreach(c, counts){
+ if(c.nd==1) singles++;
+ else if(c.nd%2==1) odds++;
+ }
+
+ llog("singles", singles, "odds", odds);
+ if(odds %2 == 0)
+ result = max<ll>(result, holes.sz-max<ll>(0, singles-2));
+ else
+ result = max<ll>(result, holes.sz-max<ll>(0, singles-1));
+ }
+ }
}
} // namespace task