From d2d58f51f5e62ac92d86c62e7bfbd7b5b2caa837 Mon Sep 17 00:00:00 2001
From: Md Arafat <57371182+arafat1802@users.noreply.github.com>
Date: Wed, 16 Aug 2023 12:46:18 +0600
Subject: [PATCH 1/2] Upload the editorial of Laser shot
---
1292/LOJ-1292.md | 96 +++++++++++++++++++++++++++++++++++++++++++++++
1292/slope.webp | Bin 0 -> 4312 bytes
2 files changed, 96 insertions(+)
create mode 100644 1292/LOJ-1292.md
create mode 100644 1292/slope.webp
diff --git a/1292/LOJ-1292.md b/1292/LOJ-1292.md
new file mode 100644
index 00000000..a7df5d57
--- /dev/null
+++ b/1292/LOJ-1292.md
@@ -0,0 +1,96 @@
+## LOJ-1292
+# Laser Shot
+
+### Simplified Version
+You have points on a flat surface (xy plane). You want to draw a line in a way that the most points possible lie on that line. What's the highest number of points that can be on one line?
+
+### Tags
+Geometry, Slope
+
+# Editorial
+
+## Observation
+1. If two lines have the same slope, they are parallel.
+
+2. If a point lies on two parallel lines, those lines are actually the same line.
+
+
+
+First, for each of the n points, pick one point and determine the slope between that point and all the other points.
+
+The most common slope value gives us the most points on a line drawn from a certain point.
+
+By repeating this process for every point, the highest count of shared slopes becomes the solution.
+
+### How to Calculate Slope:
+
+If two points are (x1, y1) and (x2, y2) then slope of those two point is,
+
+Let, a = x2 - x1, b = y2 - y1 , g = gcd(a, b).
+
+slope = (a/gcd)/(b/gcd)
+
+# Complexity Analysis
+
+## Time Complexity
+O(n2logn)
+
+## Memory Complexity
+O(n)
+
+# Program Code
+
+```c++
+#include
+using namespace std;
+int cas = 0;
+pair calculate_slope(vector point1, vectorpoint2)
+{
+ int dx = point1[0] - point2[0];
+ int dy = point1[1] - point2[1];
+ int gcd = __gcd(dx, dy);
+
+ dx /= gcd;
+ dy /= gcd;
+ return {dx,dy};
+}
+void solve()
+{
+ int n;
+ cin >> n;
+ vector>points;
+ for(int i = 0; i < n; i++){
+ int x,y;
+ cin >> x >> y;
+ points.push_back({x,y});
+ }
+
+ map,int>slope_count;
+ int max_point = 0;
+
+ for(int i = 0; i < points.size(); i++){
+ slope_count.clear();
+ for(int j = i+1; j < points.size(); j++){
+ //calculate the slope.
+ pairslope = calculate_slope(points[i], points[j]);
+ slope_count[slope]++;
+ }
+ // Finding the maximum number of points in a single line
+ for(auto it : slope_count){
+ max_point = max(max_point, it.second);
+ }
+ }
+
+ cout << "Case " << ++cas << ": " << max_point+1 << "\n";
+}
+int main()
+{
+ ios_base :: sync_with_stdio(0);
+ cin.tie(0);
+ int t;
+ cin >> t;
+ while(t--)solve();
+
+ return 0;
+}
+```
\ No newline at end of file
diff --git a/1292/slope.webp b/1292/slope.webp
new file mode 100644
index 0000000000000000000000000000000000000000..5f6380352e8c8fbd435baba6a3cbf8fe634ec91c
GIT binary patch
literal 4312
zcmV;}5GU_aNk&G{5C8yIMM6+kP&iD(5C8x#;(=NK@4=9fBthlW=X6eo`#%sfV~}m6
zd!|C2(>tBh{HsmdfEm+s2MGoMq&_|YZ$Sni4~9>im4FN^y3gMPnLTu#y|zzaK>#4R
zZ5t)4>TnsZh1`^v8di!)5rB3mi;A4q|Nj>-GkcN5PA^6DUlwg!Ra>poHdiXiR_Qr_
z#&cg^2w2dXv$M0Nm}auQwX7NLprG9h+>{edwzrZsmu;B@LB*;HEaey-x92&Wg;gb3
z!ZG@HDmeL;_HhciYnnix9h#<5Cor_4J5k5Q*;$Q%Cmzy_0xB+0pWuZwFeAPMP@%Bq
zMC^h@3xzT^r026**ms@D>vdj=q074P4?!YO=8e@ro#<<);CoaYbR^jy!Lpc28Qe>>h2qWrD<{rC0K`7(+4?iDGbZA
z(5-jeSZnGY-}bxRGajn}>8XxWMDHisr}pA
zo_zch5pm7h86K-G$#YxDXV~SiUJ{NzFApSO(xTv0(1?vG9Y3_AuT;Wza2Vg1oOa+Z
zJXRwu1+3r$Rba2PHlqz?AFCWS_(DO+JNFLBJAuh#r%zb{e9rocPsz_e5eR&?6l>dXZ
zC%@)XtWSfZ*pJG4St9wCye&S?;&;>1I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cuYb{hW5s}h>s+{A~{Qf_pz5frl
z_x};?{eQT<-$ZlM6ts(hi*lmL_Exgyv;Us9o6DPmMvBXcCfi%dn#=YQ|Lu{h@%?|e
zy&DDqfFL1ZtF*^()Ty8*>535Lfp^2@TtwCI0tu3}2VS0?-646Il#Nm!Na|h;RZ}GE
zkMViP|AM3x(;s+qc9ysjq5{E-)Rho5$av@zB`c8O8_C~MAQ!`AOX{)LAI
Date: Fri, 10 May 2024 10:56:25 +0600
Subject: [PATCH 2/2] Rename LOJ-1292.md to en.md
---
1292/{LOJ-1292.md => en.md} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename 1292/{LOJ-1292.md => en.md} (99%)
diff --git a/1292/LOJ-1292.md b/1292/en.md
similarity index 99%
rename from 1292/LOJ-1292.md
rename to 1292/en.md
index a7df5d57..1bfd3253 100644
--- a/1292/LOJ-1292.md
+++ b/1292/en.md
@@ -93,4 +93,4 @@ int main()
return 0;
}
-```
\ No newline at end of file
+```