Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x1, y1 = [ int(k) for k in raw_input('').split() ] x2, y2 = [ int(k) for k in raw_input('').split() ] n = int(raw_input('')) a = [0]*n b = [0]*n c = [0]*n for i in xrange(n): a[i],b[i],c[i] = [ int(k) for k in raw_input('').split() ] #d = [0]*n count = 0 for i in xrange(n): if ( a[i]*x1+b[i]*y1+c[i] )*...
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import j...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#498A [x1,y1] = list(map(int,input().split())) [x2,y2] = list(map(int,input().split())) n = int(input()) s = 0 for i in range(n): [a,b,c] = list(map(int,input().split())) if (a*x1+b*y1+c)*(a*x2+b*y2+c) < 0: s += 1 print(s)
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import collections def cross(line1, line2): s1 = get_s(line1.first, line1.second, line2.first) s2 = get_s(line1.first, line1.second, line2.second) if not (s1 > 0) ^ (s2 > 0): return False s3 = get_s(line2.first, line2.second, line1.first) s4 = get_s(line2.first, line2.second, line1.secon...
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { public static void main(String args[]) throws NumberFormatException,IOException { Stdin in = new Stdin(); PrintWriter out = new PrintWr...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long x1, y1, x2, y2; long long a, b, c; long long t1, t2; int n, i, count = 0; cin >> x1 >> y1; cin >> x2 >> y2; cin >> n; for (i = 0; i < n; i++) { cin >> a >> b >> c; t1 = a * x1 + b * y1 + c; t1 = (t1 == 0 ? 0 : (t1 > 0 ? 1 :...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
xhome, yhome = [int(x) for x in input().split()] xuni, yuni = [int(x) for x in input().split()] n_roads = int(input()) n_steps = 0 for i in range(n_roads): a, b, c = [int(x) for x in input().split()] hline = (a*xhome) + (b*yhome) + c uline = (a*xuni) + (b*yuni) + c if hline * uline < 0: n_steps ...
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.awt.Point; import java.util.Scanner; /* 1 1 -1 -1 2 0 1 0 1 0 0 1 1 -1 -1 3 1 0 0 0 1 0 1 1 -3 */ public class c { static class LineSegment { long a; long b; long c; LineSegment(int a, int b, int c) { this.a = a; this.b = b; this.c = c; } float eq (int x, int y) { ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long x1, x2, y1, y2, n; cin >> x1 >> y1 >> x2 >> y2 >> n; long long a, b, c; int steps = 0; for (int i = 0; i < n; i++) { cin >> a >> b >> c; bool sign0, sign1; sign0 = a * x1 + b * y1 + c > 0; sign1 = a * x2 + b * y2 + c > 0; ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Kraken */ public class Main { public static void main(String[] args) { InputStream inputSt...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
read_line = lambda: [int(i) for i in input().split()] x0, y0 = read_line() x1, y1 = read_line() print(sum((a * x0 + b * y0 + c) * (a * x1 + b * y1 + c) < 0 for a, b, c in (read_line() for i in range(int(input())))))
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
def input_split(f): return map(f, input().split()) def main(): x1, y1 = input_split(int) x2, y2 = input_split(int) n = int(input()) count = 0 for i in range(n): a, b, c = input_split(int) if (a*x1+b*y1+c) * (a*x2+b*y2+c) < 0: count+=1 print(count) main()
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:36777216") using namespace std; inline long long MAX(long long a, long long b) { return (a > b) ? (a) : (b); } inline long long MIN(long long a, long long b) { return (a < b) ? (a) : (b); } int main() { int const sz = 1e3 + 10; long long m, n, k, step = 1, cn...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; struct point { long long x; long long y; long long z; }; point arr[305]; int main() { long long x1, y1, x2, y2, cnt, b1, c1, i, n, x, y, fx, mx, fy, my, val1, val2; cin >> x1 >> y1 >> x2 >> y2; cnt = 0; cin >> n; for (i = 0; i < n; i++) { cin >> arr[i].x...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long a, b; cin >> a >> b; long long c, d; cin >> c >> d; int n; cin >> n; vector<long long> A(n), B(n), C(n); for (int i = 0; i < n; i++) { cin >> A[i] >> B[i] >> C[i]; } int ans = 0; for (int i = 0; i < n; i++) { long long va...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); long x1 = s.nextInt(), y1 = s.nextInt(); long x2 = s.nextInt(), y2 = s.nextInt(); int n = s.nextInt(), ans = 0; for (int i = 0; i < n; i++) { int a = s.nextInt(), b = s.n...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1; int x2, y2; int n; while (scanf("%d%d", &x1, &y1) != EOF) { long long m = 0; scanf("%d%d", &x2, &y2); scanf("%d", &n); while (n--) { long long a, b, c; scanf("%I64d%I64d%I64d", &a, &b, &c); long long s = a *...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
//package HackerEarthA; import java.io.*; import java.util.*; import java.util.Map.Entry; import java.text.*; import java.math.*; import java.util.regex.*; import javafx.scene.layout.Priority; import java.awt.Point; /** * * @author prabhat // use stringbuilder, priorityQueue */ public class easy18{ public st...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
def sign(a): if a>=0: return 1 else: return 0 pt1 = map(int,raw_input().split()) pt2 = map(int,raw_input().split()) q=input() arr=[] for i in range(q): p =map(int,raw_input().split()) arr.append(p) z=0 for i in arr: if (sign(i[0]*pt2[0]+i[1]*pt2[1]+i[2]) !=sign(i[0]*pt1[0]+i[1]*pt1[1]+i[2])): z=z+1 print z
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; public class Div2_284 { static public void main(String[] args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] in = br.readLine().split(" "); long x1=Long.parseLong(in[0]); long y1=Long.parseL...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; struct point { int x, y; void input() { cin >> x >> y; } }; struct line { int a, b, c; void input() { cin >> a >> b >> c; } long long atPoint(point p) { return a * 1LL * p.x + b * 1LL * p.y + c; } } line1, line2; bool isPositive(long long x) { return x == abs(x); ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; bool check(double x, double y, double x1, double x2, double y1, double y2) { bool f1 = (x <= x1 && x >= x2) || (x >= x1 && x <= x2); bool f2 = (y <= y1 && y >= y2) || (y >= y1 && y <= y2); return (f1 && f2); } int main() { ios_base::sync_with_stdio(false); double ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import re, sys, math, string, operator, functools, fractions, collections from random import * sys.setrecursionlimit(10**7) dX= [-1, 1, 0, 0,-1, 1,-1, 1] dY= [ 0, 0,-1, 1, 1,-1,-1, 1] RI=lambda: list(map(int,input().split())) RS=lambda: input().rstrip().split() mod=1e9+7 ################################################...
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d, i, j, k, x, y, z, m, n, ar[100005], x1, y1, x2, y2, p, q, l, flag, cnt, ans; char s[100005]; flag = cnt = 0; scanf("%I64d%I64d", &x1, &y1); scanf("%I64d%I64d", &x2, &y2); scanf("%I64d", &n); for (int i = 0; i <= n - 1; ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x1, y1 = [int(x)for x in raw_input().split(' ')] x2, y2 = [int(x)for x in raw_input().split(' ')] n = int(raw_input()) l = [[int(x)for x in raw_input().split(' ')]for i in xrange(n)] t = [y1 - y2, x2 - x1, x1 * (y2 - y1) - y1 * (x2 - x1)] def det (a, b, c, d): return float(a * d - b * c) def intersect(l1, l2): ...
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
home = map(int, raw_input().split()) univ = map(int, raw_input().split()) line = None if home[0] == univ[0]: line = [1,0,-home[0]] elif home[1] == univ[1]: line = [0,1,-home[1]] else: slope = (univ[1]-home[1])/(univ[0]-home[0]) line = [slope, -1, univ[1]-slope*univ[0]] n = int(raw_input()) road = None c...
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x1,y1=map(int,raw_input().split()) x2,y2=map(int,raw_input().split()) n=int(raw_input()) tt=0 for i in range(n): a,b,c=map(int,raw_input().split()) if((x1*a+y1*b+c)*(x2*a+y2*b+c)<0): tt+=1 print tt
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
from sys import stdin R = lambda: map(int, stdin.readline().split()) x1, y1 = R() x2, y2 = R() ans = 0 for _ in range(int(input())): a, b, c = R() if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0: ans += 1 print(ans)
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x,y = map(int,input().split()) x1,y1 = map(int,input().split()) n=int(input()) ans=0 for i in range(n): a,b,c=map(int,input().split()) if((a*x+b*y+c)*(a*x1+b*y1+c)<0): ans+=1 print(ans)
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.awt.geom.Line2D; import java.util.Scanner; public class CrazyTown { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double x1 = sc.nextInt(), y1 = sc.nextInt(); double x2 = sc.nextInt(), y2 = sc.nextInt(); int n = sc.nextInt(); double minx = Math.min(x1, x2) - 1, m...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long x1, y1, x2, y2, n, a, b, c; scanf("%I64d%I64d", &x1, &y1); scanf("%I64d%I64d", &x2, &y2); cin >> n; int ans = 0; while (n--) { scanf("%I64d%I64d%I64d", &a, &b, &c); long long s1 = a * x1 + b * y1 + c; long long s2 = a * x2 + b ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.math.BigDecimal; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.math.B...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; long long a, b, c, x1, y1, x2, y2; cin >> x1 >> y1; cin >> x2 >> y2; cin >> n; int ans = 0; for (int i = 1; i <= n; i++) { cin >> a >> b >> c; long long t1 = a * x1 + b * y1 + c; long long t2 = a * x2 + b * y2 + c; if ((t1 >...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; long long a[333]; long long b[333]; long long c[333]; long long hx, hy; long long ux, uy; int isThrough(int idx) { if (b[idx] == 0) { long long tmp = -c[idx]; if ((hx * a[idx]) <= tmp && tmp <= (ux * a[idx])) return 1; if ((ux * a[idx]) <= tmp && tmp <= (hx * ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Linked...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; long long aa; int main() { int x1, y1, x2, y2; int n; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); scanf("%d", &n); int ans = 0; while (n--) { long long a, b, c; scanf("%lld%lld%lld", &a, &b, &c); if ((a * x1 + b * y1 + c > 0 && a * x2 + b * y2 + c < 0) ||...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ProblemA { BufferedReader rd; private ProblemA() throws IOException { rd = new BufferedReader(new InputStreamReader(System.in)); compute(); } private void compute() throws IOExcep...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; long long int sx, sy, dx, dy, ans, i, n, k, a, b, c, d, e; int main() { cin >> sx >> sy; cin >> dx >> dy; cin >> n; for (i = 1; i <= n; i++) { cin >> a >> b >> c; d = a * sx + b * sy + c; e = a * dx + b * dy + c; if (((d < 0) && (e > 0)) || ((e < 0) ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) count = 0 for _ in range(int(input())): a, b, c = map(int, input().split()) f = lambda x, y: a * x + b * y + c if f(x1, y1) * f(x2, y2) < 0: count += 1 print(count)
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.math.BigInteger; import java.util.*; import java.io.*; public class Main3 { public static void main(String args[]) { Scanner in = new Scanner(System.in); while(in.hasNext()) { Long sx = in.nextLong(); Long sy = in.nextLong(); Long fx = in.nextLong(...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int sgn(long long x) { if (x > 0) return 1; if (x < 0) return -1; return 0; } int main() { long long x_1, x_2, y_1, y_2; scanf("%I64d%I64d%I64d%I64d", &x_1, &y_1, &x_2, &y_2); int n; scanf("%d", &n); long long a, b, c; int ans = 0; for (int i = 1; i <= n...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long x1, x2, y1, y2, n, a, b, c, p, pp, ans = 0; pp = -p; cin >> x1 >> y1 >> x2 >> y2 >> n; while (n--) { cin >> a >> b >> c; p = a * x1 + b * y1 + c; pp = a * x2 + b * y2 + c; if (p > 0 && pp < 0) ans++; else if (p < 0 &&...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.Scanner; public class Main { public static int ori(long x,long y,int a,int b,int c){ long tmp=a*x+b*y+c; return (tmp)>0?1:-1; } public static void main(String[] args) { // TODO Auto-generated method stub long x1,y1,x2,y2; int n; int a,b,c; ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int ax, ay, bx, by; cin >> ax >> ay; cin >> bx >> by; int n; cin >> n; vector<long long> a(n); vector<long long> b(n); vector<long long> c(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i] >> c[i]; } int k = 0; for (int i = 0; i ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.Scanner; /** * * @author mav3n * */ public class C284 { class Point{ long x; long y; public Point(long x,long y){ this.x=x; this.y=y; } } class Line{ long a; long b; long c; ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int n, result = 0; cin >> n; for (int i = 0; i < n; i++) { double a, b, c; cin >> a >> b >> c; long long value1 = (a * x1) + (b * y1) + c; long long value2 = (a * x2) + (b * y2) + c; ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 310; const double eps = 1e-5; struct Point { double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator-(const Point& B) const { return Point(x - B.x, y - B.y); } }; Point A, B; Point P, dir; int n; int dcmp(const double& x) { if ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.*; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); long hox = sc.nextInt(); //homeX long hoy = sc.nextInt(); //homeY long scx = sc.nextInt(); //schoX long scy = sc.nextInt(); //schoY long count = 0; long line = sc.nextIn...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R284_Div2_C { FastReader in; PrintWriter out; public static void main(String[] args) { new R284_Div2_C().run(); } void run() { in = new FastReader(System.in...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const int INF = 2 * 1e9 + 10; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long x1, y1; cin >> x1 >> y1; long long x2, y2; cin >> x2 >> y2; int n; cin >> n; int ans = 0; for (int i = 0; i < n; i++) { long long a, b, c; ci...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long x1, y1, x2, y2, n, a, b, ans = 0, c; cin >> x1 >> y1 >> x2 >> y2 >> n; for (long long i = 0; i < n; ++i) { cin >> a >> b >> c; long long value1 = a * x1 + b * y1 + c; long long value2 = a * x2 + b * y2 + c; if ((value1 < 0 && val...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
px,py = map(int,input().split()) qx,qy = map(int,input().split()) n,s= int(input()),0 for _ in range(n): a,b,c = map(int,input().split()) if not a: x,y = 0,-c/b else: x,y = -c/a,0 s += ((px-x)*a+(py-y)*b)*((qx-x)*a+(qy-y)*b)<0 print(s) # C:\Users\Usuario\HOME2\Programacion\ACM
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x1,y1=raw_input().split() x2,y2=raw_input().split() x1=int(x1) x2=int(x2) y1=int(y1) y2=int(y2) n=int(raw_input()) ret=0 while (n): a,b,c=raw_input().split() r1=int(a)*x1+int(b)*y1+int(c) r2=int(a)*x2+int(b)*y2+int(c) if (r1>0 and r2<0)or(r1<0 and r2>0): ret+=1 n-=1 print ret
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 2005; const int maxm = 4005; int main() { long long m, a, b, c, d, z, x, y; int n; while (~scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d)) { if (c < a) { swap(a, c); swap(b, d); } scanf("%d", &n); in...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
def crazy(n,m,func): func=func.strip().split() abc=[] func=[int(func[i]) for i in range(len(func))] for i in range(0,len(func),3): abc.append([func[i],func[i+1],func[i+2]]) #print(abc) pict=points(n,m) #print(pict) count=0 for j in range(len(abc)): #if abc[j][0]*pict[...
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.*; public class Solution{ static double THRESHOLD = 1e-6; public static void main(String[] args){ Scanner in = new Scanner(System.in); int x1 = in.nextInt(); int y1 = in.nextInt(); int x2 = in.nextInt(); int y2 = in.nextInt(); //double s1 = (doubl...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
def ccw(A,B,C): return (C[1]-A[1])*(B[0]-A[0]) > (B[1]-A[1])*(C[0]-A[0]) def intersect(A,B,C,D): return ccw(A,C,D) != ccw(B,C,D) and ccw(A,B,C) != ccw(A,B,D) def main(home,uni,n,l): ans = 0 x0 = min(home[0], uni[0]) - 1 x1 = max(home[0], uni[0]) + 1 y0 = min(home[1], uni[1]) - 1 y1 = max(ho...
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.Scanner; public class CrazyTown { CrazyTown() { Scanner scanner = new Scanner(System.in); long x1, y1, x2, y2, n, a, b, c; x1 = scanner.nextLong(); y1 = scanner.nextLong(); x2 = scanner.nextLong(); y2 = scanner.nextLong(); n = scanner.nextLong(); ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 0, -1, 1}; int dy[] = {-1, 1, 0, 0}; int n; int sx, sy, tx, ty; bool side(int a, int b, int c, int first, int second) { return (long long)a * first + (long long)b * second + (long long)c < 0LL; } int main() { scanf("%d %d %d %d", &sx, &sy, &tx, &ty); sc...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long n, q, w, x, y, x2, y2, a, b, c, ans = 0; cin >> x >> y >> x2 >> y2 >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; q = x * a + y * b + c; w = x2 * a + y2 * b + c; if ((q < 0) && (w > 0)) ans++; else if ((q > 0) ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class ExtendedEuclid { static final double EPS = 1e-9; public static voi...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long x1, y1, x2, y2, n, a, b, c, temp1, temp2; cin >> x1 >> y1; cin >> x2 >> y2; cin >> n; int ans = 0; for (int i = 0; i < n; ++i) { cin >> a >> b >> c; temp1 = a * x1 + b * y1 + c; temp1 /= abs(temp1); temp2 = a * x2 + b * y2 ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; struct Point { Point operator-(const Point& p) const { return Point{x - p.x, y - p.y}; } void normalize() { float norm = sqrt(x * x + y * y); x /= norm; y /= norm; } float x, y; } h, u; struct Line { float a, b, c; }; int n; float cross(Point v1, Point...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; bool intersect(int64_t a, int64_t b, int64_t c, int64_t x1, int64_t x2, int64_t y1, int64_t y2) { int64_t p1 = a * x1 + b * y1; int64_t p2 = a * x2 + b * y2; return (p1 > (-c)) ^ (p2 > (-c)); } int main() { int64_t hx, hy; int64_t ux, uy; int64_t ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> const long long INF = 1000000007; const double cp = 2 * asin(1.0); const double eps = 1e-9; const long long mod = 1000000007; using namespace std; int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); long long x1, y1, x2, y2, n, cnt = 0; cin >> x1 >> y1 >> x2 >> y2 >> n; for ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Crazytown { public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String brr[]=br.readLine().trim().split(" "); ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import sys a=map(int,sys.stdin.readline().split()) b=map(int,sys.stdin.readline().split()) n=input() ans=0 for i in range(0,n): l=map(int,sys.stdin.readline().split()) val1=l[0]*a[0]+l[1]*a[1]+l[2] val2=l[0]*b[0]+l[1]*b[1]+l[2] if(val1*val2<=0): ans+=1 print ans
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; /* * To change this license header, choose License Headers in Project Properties. * To change this template ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class CrazyTown { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Point home = new Point(sc.nextInt(), sc.nextInt()); Point uni = new Point(sc.nextInt(), sc.nextInt()); int n = sc.nextInt();...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long int x1, x2, y1, y2; scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2); long long int n; long long int i; scanf("%lld", &n); int a, b, c, count = 0; for (i = 0; i < n; i++) { scanf("%d %d %d", &a, &b, &c); long long int tmp1 = a * ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int n; long long xa, ya, xb, yb; int ans; int main() { cin >> xa >> ya >> xb >> yb; cin >> n; for (int i = 0; i < n; i++) { long long a, b, c; cin >> a >> b >> c; long long aa = a * xa + b * ya + c; long long bb = a * xb + b * yb + c; if (aa < 0 &&...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.*; public class Crazy_towm_499_C { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int[] a = new int[2]; int[] b = new int[2]; a[0] = in.nextInt(); a[1] = in.nextInt(); b[0] = in.nextInt(); b[1] = in.nextInt(); int n =...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#!/usr/bin/env python #-*- coding:utf-8 -*- import sys import math from fractions import Fraction, gcd from decimal import Decimal, getcontext from itertools import product, permutations, combinations getcontext().prec = 100 MOD = 10**9 + 7 EPS = 0.1 ** 7 x1, y1 = map(int, raw_input().split()) x2, y2 = map(int, raw_...
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 5, INF = 0x3f3f3f3f; int main() { double x0, y0, x1, x2, y1, y2, a1, a2, b1, b2, c1, c2; scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2); if (x1 == x2 && y1 == y2) { printf("0\n"); return 0; } if (x1 == x2) { a1 = 1, b1 = 0, c1 = (-1 *...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
//package home; import java.awt.Point; import java.io.BufferedReader; import java.io.InputStreamReader; public class CrazyTown { public static void main(String []args) throws Exception{ BufferedReader br=new BufferedReader(new InputStreamReader (System.in)); String[]sa=br.readLine().split(" "); String[]sb=br.r...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); long long n, x1, y1, x2, y2; cin >> x1 >> y1; cin >> x2 >> y2; cin >> n; int res = 0; for (int i = 0; i < n; i++) { long long a, b, c; cin >> a >> b >> c; long long dir1 = a * x1 + b * y1 + c; long lon...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const double eps = 1e-5, pi = acos(-1.0); const long long inf = 2000000009; struct pt { double x, y; pt() {} pt(double x, double y) : x(x), y(y) {} } res; struct line { double a, b, c; line() {} line(pt p, pt q) { a = q.y - p.y; b = p.x - q.x; c = -a...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; inline int two(int n) { return 1 << n; } inline int test(int n, int b) { return (n >> b) & 1; } inline void set_bit(int& n, int b) { n |= two(b); } inline void unset_bit(int& n, int b) { n &= ~two(b); } inline int last_bit(int n) { return n & (-n); } inline int ones(int n) ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C499_CrazyTown { private static final long MOD = 1000000007; private static BufferedReader br = new BufferedReader(new InputStreamReader(Syst...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; struct line { long long int a, b, c; }; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; long long int n; cin >> n; line obj[n]; for (long long int i = 0; i < n; i++) { ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter o...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x, y = map(int, input().split()) x1, y1 = map(int, input().split()) n = int(input()) steps = 0 for i in range(n): a, b , c = map(int, input().split()) p = (a * x + b * y + c) q = (a * x1 + b * y1 + c) if (p * q < 0): steps += 1 print(steps)
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') BUF...
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int x, y, X, Y; int a0, b0, c0; bool ok() { if (b0 == 0) { if ((long double)-c0 / a0 >= min(x, X) && (long double)-c0 / a0 <= max(x, X)) return true; return false; } long double k = (long double)-a0 / b0; long double b = (long double)-c0 / b0; ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.InputStreamReader; import java.io.IOException; import java.util.InputMismatchException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the to...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int i, n; long long x2, y2, x1, y1, a, b, c, ans; scanf("%lld%lld", &x1, &y1); scanf("%lld%lld", &x2, &y2); scanf("%d", &n); ans = 0; for (i = 1; i <= n; i++) { scanf("%lld%lld%lld", &a, &b, &c); long long j = a * x1 + b * y1 + c; long...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); long long xh, yh, xu, yu; cin >> xh >> yh >> xu >> yu; int n; cin >> n; int ans = 0; for (int i = 0; i < n; ++i) { long long a, b, c; cin >> a >> b >> c; if (a < 0) { a = -a, ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
def clockwise(x, y, a, b, c): return a * x + b * y + c < 0 x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) ans = 0 for _ in range(int(input())): a, b, c = map(int, input().split()) if clockwise(x1, y1, a, b, c) != clockwise(x2, y2, a, b, c): ans += 1 print(ans)
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Main { static final double EPS = 1e-6; public static void main(String[] args) throws IOException { PrintWriter pw = new PrintWriter(System.out); Scanner sc = new Scanner(System.in); Point home = new Poi...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; import java.io.InputStream; import java.io.InputStreamReader; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } int main() { fast(); long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; long long n; cin >> n; long long ct = 0; for (int i = 0; i < n; i++) { long lo...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const int inv = 1000000000; const int minv = -inv; const int max_n = 310; long long xx1, yy1; long long xx2, yy2; long long a, b, c; int res; int n; int main() { cin >> xx1; cin >> yy1; cin >> xx2; cin >> yy2; scanf("%d", &n); res = 0; for (int i = 0; i < n; +...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.*; import java.io.*; import java.math.BigInteger; import java.math.MathContext; import java.text.DecimalFormat; import java.text.Format; import static java.lang.Math.*; import static java.util.Arrays.*; public class Main { public static void main(String[] args) throws IOException{ InputReader...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class CrazyTown { public static void main(String[] args) { // TODO Auto-generated method stu...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.*; import java.util.*; public class cf284A { public static void main(String[] args) throws Exception { // BufferedReader in = new BufferedReader(new FileReader("cf284A.in")); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = in.readLine(); lon...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @auth...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; struct cord { long long int x, y; }; int main(int argc, const char* argv[]) { cord home, dest; cin >> home.x >> home.y; cin >> dest.x >> dest.y; long long int n, x, y, z; cin >> n; long long int ans = 0; for (int i = 0; i < n; i++) { cin >> x >> y >> z; ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); long long int x1, y1, x2, y2, i, j, k, ans = 0, n, a, b, c; cin >> x1 >> y1; cin >> x2 >> y2; cin >> n; while (n--) { cin >> a >> b >> c; int f1 = 1, f2 = 1; if (a * x1 + b * y1 + c < 0) f1 = 0; if (a * x2 + ...
CPP