prompt
string
response
string
Problem: 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class crazyTown { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); double xS = sc.nextInt(); double yS...
Problem: 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 ...
import java.lang.String; import java.lang.System; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x1 = sc.nextInt(); int y1 = sc.nextInt(); int x2 = sc.nextInt(); int y2...
Problem: 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 ...
/* Keep solving problems. */ import java.math.BigInteger; import java.util.*; import java.io.*; public class CFA { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; final long MOD = 1000L * 1000L * 1000L + 7; int[] dx = {0, -1, 0, 1}; int[] dy = {1, 0, -1, 0}; voi...
Problem: 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(br); ...
Problem: 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 ...
import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; 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.io.InputStream; /** * Built using...
Problem: 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 ...
import java.util.*; public class crazyTown { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double x1 = sc.nextDouble(); double y1 = sc.nextDouble(); double x2 = sc.nextDouble(); double y2 = sc.nextDouble...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long sign(long long k) { if (k >= 0) return 1LL; else return -1LL; } int main() { long long a, b, c; long long i, j, k, l; long long e, f, g, h; long long n; cin >> e >> f >> g >> h; cin >> n; long long z = 0; for (i = 0; i < n; i++) { c...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long int x1, x2, y1, y2, a, b, c, v1, v2, n, ans; while (cin >> x1 >> y1) { ans = 0; cin >> x2 >> y2; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; v1 = a * x1 + b * y1 + c; v2 = a * x2 + b * y2 + c; ...
Problem: 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 ...
import java.util.*; public class Main { public static void main(String args[]){ Scanner sc = new Scanner(System.in); long x1 = sc.nextInt(), y1 = sc.nextInt(); long x2 = sc.nextInt(), y2 = sc.nextInt(); int n = sc.nextInt(); int cnt = 0; for(int i=0;i<n;i++){ int a = sc.nextInt(), b = sc.nextI...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long x1, x2, y, y2, n, p, q, a, b, c; int main() { int cnt = 0; cin >> x1 >> y; cin >> x2 >> y2; cin >> n; while (n--) { cin >> a >> b >> c; p = a * x1 + b * y + c; q = a * x2 + b * y2 + c; if ((p > 0 && q < 0) || (p < 0 && q > 0)) cnt++; } ...
Problem: 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 ...
from sys import stdin ibuf = stdin.readlines() x1, y1, x2, y2, n = [int(x) for x in ibuf[0].split()] + [int(x) for x in ibuf[1].split()] + [int(ibuf[2])] s = [(int(a), int(b), int(c)) for a, b, c in [x.split() for x in ibuf[3:]]] k1, k2 = [x1 * a + y1 * b + c for a, b, c in s], [x2 * a + y2 * b + c for a, b, c in s] p...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; typedef struct { long long a, b, c; } line; int main() { int x1, y1, x2, y2, n; cin >> x1 >> y1 >> x2 >> y2; cin >> n; vector<line> arr(n); for (int i = 0; i < n; i++) cin >> arr[i].a >> arr[i].b >> arr[i].c; int ans = 0; for (int i = 0; i < n; i++) { lo...
Problem: 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 ...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:66777216") using namespace std; int a, b, c, d, n, m, k; pair<int, int> t1, t2; int main() { scanf("%d%d%d%d", &t1.first, &t1.second, &t2.first, &t2.second); int ans = 0; scanf("%d", &n); for (int _n((n)-1), i(0); i <= _n; i++) { scanf("%d%d%d", &a, &...
Problem: 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 ...
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** *...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; double n, ans = 0; cin >> n; for (int i = 0; i < n; i++) { double a, b, c; cin >> a >> b >> c; if ((a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0) ans++; } cout << ans << endl; r...
Problem: 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 ...
x,y = map(int,raw_input().split()) ux, uy = map(int, raw_input().split()) def ev(a,b,c,r,s): return a * r + b * s + c N = int(raw_input()) count = 0 for i in range(N): a,b,c = map(int, raw_input().split()) count += (ev(a,b,c,x,y) * ev(a,b,c,ux,uy) < 0) print count
Problem: 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 ...
import java.util.*; import java.io.*; import javafx.geometry.Point2D; /* Mighty Cohadar */ public class Alfa { static class Line { final double a; final double b; final double c; Line(double a, double b, double c) { this.a = a; this.b = b; this.c = c; } public String toString() { return Strin...
Problem: 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 ...
ans = 0 x1, y1 = map(int,raw_input().split()) x2, y2 = map(int,raw_input().split()) for _ in range(input()): a,b,c = map(int,raw_input().split()) if (a*x1 + b*y1 + c)*(a*x2 + b*y2 + c) < 0: ans += 1 print ans
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long inp; long long i1, i2, i3, i4, i5, i6, i7, i8; long long mov = (long long)1e9 + 7; using Point = complex<double>; const double kPi = 4.0 * atan(1.0); const double kEps = 1e-9; double dot(Point a, Point b) { return (conj(a) * b).real(); } double cross(Point a, Poin...
Problem: 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 ...
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) ans = 0 for i in range(int(input())): a, b, c = map(int, input().split()) if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0: ans += 1 print(ans)
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cin.sync_with_stdio(0); long long x1, y1; cin >> x1 >> y1; long long x2, y2; cin >> x2 >> y2; long long n; cin >> n; long long ans = 0; while (n--) { long long a, b, c; cin >> a >> b >> c; long long s1 = a * x1 + b * ...
Problem: 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 ...
import java.util.*; public class Tester { public static void main(String[] args) { Scanner s = new Scanner(System.in); long x1=s.nextLong(); long y1=s.nextLong(); long x2=s.nextLong(); long y2=s.nextLong(); int n=s.nextInt(); long a[] = new long[n]; long b[] = new long[n]; long c[] = new long...
Problem: 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 ...
import sys x1, y1 = map(int, sys.stdin.readline().split()) x2, y2 = map(int, sys.stdin.readline().split()) n = int(sys.stdin.readline()) a = [0] * n b = [0] * n c = [0] * n for i in xrange(n): a[i], b[i], c[i] = map(int, sys.stdin.readline().split()) count = 0 for i in xrange(n): if (a[i] * x1 + b[i] * y1 + c[...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; long long n, a, b, c; cin >> n; if (y2 < y1) { swap(y1, y2); swap(x1, x2); } else if (x2 < x1) { swap(y1, y2); swap(x1, x2); } int count = 0; for (int i = 0; i < n; i++) { ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } void JAISHREERAM() { long long int n, i, j, ans = 0; double xa, xb, ya, yb, a, b, c, x, y; cin >> xa >> ya >> xb >> yb >> n; for (long long int i = 0; i < n; i++)...
Problem: 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 ...
import java.awt.*; import java.io.*; import java.math.BigInteger; import java.util.*; public class TaskC { static Long[][]dp; static int n, m, ans; static StringBuilder[]s1,s2; static int[]arr; public static void main(String[] args) throws Exception { ...
Problem: 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 ...
// package Div2; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.Stack; public class Sketch { public static void main(String[] args){ Scanner input = new Scanner(System.in); long[] x = new long[2]; long[] y = n...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; double a, b, c; a = -1 * (y2 - y1); b = (x2 - x1); c = (x1 * y2) - (y1 * x2); int num = 0; int n; cin >> n; double ai, bi, ci; if (a != 0 && b != 0) { for (int i = 0; i < n; i++) { ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long x[2], y[2]; for (int i = 0; i < 2; i++) cin >> x[i] >> y[i]; int n; cin >> n; int ans = 0; long long a, b, c; for (int i = 0; i < n; i++) { cin >> a >> b >> c; if ((a * x[0] + b * y[0] + c) < 0 && (a * x[1] + b * y[1] + c) > 0) ...
Problem: 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 ...
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) n = int(input()) ans = 0 for i in range(n): a, b, c = map(int, input().split()) if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0: ans += 1 print(ans)
Problem: 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Hashtable; public class cSolution{ public static void main(String args[]){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] home = br.readLine().split("\n")[0].s...
Problem: 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 ...
// package Mathematical; 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 line[]=br.readLin...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; double a[310], b[310], c[310]; struct POINT { double x; double y; POINT(double a = 0, double b = 0) { x = a; y = b; } }; struct LINE { double a; double b; double c; LINE(double d1 = 1, double d2 = -1, double d3 = 0) { a = d1; b = d2; c = ...
Problem: 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class CrazyTown { public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); PrintWri...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); long long hx, hy, ux, uy, a, b, c, cnt, d1, d2; int n; cin >> hx >> hy >> ux >> uy; cin >> n; cnt = 0; for (int i = 0; i < n; i++) { cin >> a >> b >> c; d1 = a * hx + b * hy + c; d2 = a * ux + b * uy + c; ...
Problem: 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 ...
import java.io.BufferedReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Tifuera */ public class Main { public static void main(Strin...
Problem: 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 ...
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C284 { public void solve() throws IOException { long xHome = nextLong(); ...
Problem: 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 ...
a=list(map(int,input().split())) b=list(map(int,input().split())) c=int(input()) d=[] for i in range(c):d+=[list(map(int,input().split()))] e=list(map(lambda j:j[0]*a[0]+j[1]*a[1]+j[2]>0,d)) f=list(map(lambda j:j[0]*b[0]+j[1]*b[1]+j[2]>0,d)) print(len(list(filter(lambda x:e[x]!=f[x],range(len(d))))))
Problem: 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 ...
import java.util.HashMap; import java.util.Scanner; /** * Created by user on 07.02.2015. */ public class Main { private static class point{ int x, y; private point(int x, int y) { this.x = x; this.y = y; } } private static class interval { point p1,...
Problem: 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 ...
xa, ya = map(int, raw_input().split()) xb, yb = map(int, raw_input().split()) n = input() res = 0 for i in range(0, n): a,b,c = map(int, raw_input().split()) d1 = a * xa + b * ya + c d2 = a * xb + b * yb + c if d1 < 0 and d2 > 0: res += 1 elif d1 > 0 and d2 < 0: res += 1 print(res)
Problem: 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 ...
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); Point home =new Point(sc.nextDouble(), sc.nextDouble()); Point uni=new Point(sc.nextDouble(), sc.nextDouble...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long f(long long a, long long b, long long c, long long x, long long y) { return (a * x) + (b * y) + c; } int main() { long long x1, y1, x2, y2, answer = 0, a, b, c, n; cin >> x1 >> y1 >> x2 >> y2 >> n; for (long long i = 0; i < n; i++) { cin >> a >> b >> c...
Problem: 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 ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long x1, yy; long long x2, y2; long long n, ans; int main() { cin >> x1 >> yy; cin >> x2 >> y2; cin >> n; for (int i = 1; i <= n; i++) { long long a, b, c; cin >> a >> b >> c; long long d1 = x1 * a + yy * b + c; long long d2 = x2 * a + y2 * b + ...
Problem: 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 ...
ct = 0 x,y = map(int,raw_input().split()) x1,y1 = map(int,raw_input().split()) n = int(raw_input()) a,b,c = [0]*n,[0]*n,[0]*n for i in range(n): a[i],b[i],c[i] = map(int,raw_input().split()) for i in range(n): d1 = a[i]*x+b[i]*y+c[i] d2 = a[i]*x1+b[i]*y1+c[i] if d1*d2<0: ct += 1 print ct
Problem: 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 ...
import java.util.Scanner; public class Town { private static boolean intersect(int[] p1, int[] p2, long[] line) { if (line[1] == 0) { int min = Math.min(p1[0], p2[0]); int max = Math.max(p1[0], p2[0]); return min < -1.0/line[0] * line[2] && max > -1.0/line[0] * line[2]; } long y1 = -1 ...
Problem: 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 ...
import java.io.*; public class CF498A { public static void solve(Input in, PrintWriter out) throws IOException { long x0 = in.nextLong(); long y0 = in.nextLong(); long x1 = in.nextLong(); long y1 = in.nextLong(); int n = in.nextInt(); int ans = 0; for (int i...
Problem: 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 ...
# coding: utf-8 # In[4]: def getToU(hauseX, hauseY, uX, uY): nOfRoads = int(input()) moves = 0 for i in range(nOfRoads): road = list(map(int,input().split())) s = road[0]*hauseX + road[1]* hauseY + road[2] e = road[0]*uX + road[1]* uY + road[2] if(s>0 and e<0)or(s<0 and e...
Problem: 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 ...
ans,v = 0,1 x1, y1 = map(int,raw_input().split()) x2, y2 = map(int,raw_input().split()) for _ in range(input()): a,b,c = map(int,raw_input().split()) if (a*x1 + b*y1 + c)*(a*x2 + b*y2 + c) < 0: ans += 1 print ans
Problem: 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 ...
home = [int(x) for x in raw_input().split()] uni = [int(x) for x in raw_input().split()] n = input() calles = 0 for i in range(n): road = [int(x) for x in raw_input().split()] if (home[0] * road[0] + home[1] * road[1] + road[2]) * (uni[0] * road[0] + uni[1] * road[1] + road[2]) < 0: calles = calles +...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int x1 = 0, y1 = 0, x2 = 0, y2 = 0; int n = 0; cin >> x1 >> y1 >> x2 >> y2 >> n; int count = 0; for (int i = 0; i < n; ++i) { int a = 0, b = 0, c = 0; cin >> a >> b >> c; int d1 = (a * 1LL * x1 + b * 1LL * y1 + c < 0 ? -1 : 1); int d2 ...
Problem: 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 ...
(x1, y1) = input().split(" ") x1 = int(x1) y1 = int(y1) (x2, y2) = input().split(" ") x2 = int(x2) y2 = int(y2) n = int(input()) lineslist = [] for i in range(n): (a, b, c) = input().split(" ") lineslist.append((int(a), int(b), int(c))) def greaterThanLine(x, y, a, b, c): return a*x + b*y + c > 0 count = ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long x0, y0, x1, y1, n, i, a, c, b; long long p1, p2; cin >> x0 >> y0; cin >> x1 >> y1; cin >> n; int ans = 0; for (i = 0; i < n; i++) { cin >> a >> b >> c; p1 = a * x0 + b * y0 + c; p...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main(void) { long long x1, y1; long long x2, y2; cin >> x1 >> y1 >> x2 >> y2; long long n; cin >> n; long long ans = 0; for (int i = 1; i <= n; i++) { long long a, b, c; scanf("%lld%lld%lld", &a, &b, &c); if (((a * x1 + b * y1 + c) > 0 && (a * ...
Problem: 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 ...
import java.util.Scanner; public class CF { static final double EPS=0; static class Point{ double x,y; public Point(double x,double y) { this.x= x; this.y=y; } } static class Line{ double a,b,c; double slope; Point pl1,pl2; public Line(double d, double bb,double e) { a=d; b=bb; c=e; ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; using namespace std; pair<long long int, long long int> p1, p2; long long int n; long long int A[300][3]; long long int solve(long long int i, pair<long long int, long long int> p) { long long int ret = A[i][0] * p.first + A[i][1] * p.second + A[i][2]; return ret; } int...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; bool opposite(int a, int b, int c, int x1, int y1, int x2, int y2) { long long point_1 = 1ll * a * x1 + 1ll * b * y1 + 1ll * c; long long point_2 = 1ll * a * x2 + 1ll * b * y2 + 1ll * c; if ((point_1 > 0 && point_2 < 0) || (point_1 < 0 && point_2 > 0)) { return tr...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long x1, aasdfasdfasdf, x2, y2, n; long long a, b, c, v1, v2; long long ans; int main() { ios_base::sync_with_stdio(0); cin >> x1 >> aasdfasdfasdf; cin >> x2 >> y2; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; v1 = a * x1 + b * aasdfasd...
Problem: 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 ...
x,y=input().split() x,y=[int(x),int(y)] a,b=input().split() a,b=[int(a),int(b)] n=int(input()) counter=0 for i in range(n): p,q,r=input().split() p,q,r=[int(p),int(q),int(r)] q1=p*x+q*y+r q2=p*a+q*b+r if q1>0 and q2<0 or q1<0 and q2>0: counter+=1 print(counter)
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; struct PT { long long x, y; }; PT p1, p2; int n; int main() { while (cin >> p1.x >> p1.y >> p2.x >> p2.y >> n) { int ans = 0; for (int i = 0; i < n; i++) { long long a, b, c; cin >> a >> b >> c; int b1, b2; if (p1.x * a + p1.y * b + c > 0...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int MX = 7 + 1e4; long double x, y, xx, yy; long double p, q, u, h; bool isit(long double a, long double b, long double c) { if (a == 0) { long double ty = -1 * c / b; return (ty < u && ty > h); } if (b == 0) { long double tx = (-1 * c) / (a); re...
Problem: 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 ...
h = input().split() h[0] = int(h[0]); h[1] = int(h[1]) u = input().split() u[0] = int(u[0]); u[1] = int(u[1]) count = 0 n = int(input()) for i in range(n): p = input().split() p[0] = int(p[0]); p[1] = int(p[1]); p[2] = int(p[2]) hp = h[0]*p[0]+h[1]*p[1]+p[2] up = u[0]*p[0]+u[1]*p[1]+p[2] if (hp > ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main(void) { long long x1, y1; long long x2, y2; scanf("%lld%lld", &x1, &y1); scanf("%lld%lld", &x2, &y2); int n; scanf("%d", &n); long long a, b, c; int ans = 0; for (int i = 1; i <= n; i++) { scanf("%lld%lld%lld", &a, &b, &c); long long xx1 =...
Problem: 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 ...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.HashMap; import java.util.StringTokenizer; public final class CF_CrazyTown { void log(int[] X){ int L=X.length; for (int i=0;i<L;i++){ logWln(X[i]+" "); } l...
Problem: 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 ...
import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.io.*; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer = new StringTokeniz...
Problem: 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 ...
import java.io.*; import java.util.*; public class AMain { String noResultMessage = "NoResult"; Parser in = new Parser(); PrintWriter out; int x1 = in.nextInteger(); int y1 = in.nextInteger(); int x2 = in.nextInteger(); int y2 = in.nextInteger(); int n = in.nextInteger(); public v...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1; scanf("%d%d", &x1, &y1); int x2, y2; scanf("%d%d", &x2, &y2); int n; scanf("%d", &n); int ans = 0; while (n--) { int a, b, c; scanf("%d%d", &a, &b); scanf("%d", &c); long long int v1 = x1 * 1LL * a + y1 * 1LL * b + c;...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long n, hx, hy, ux, uy, a, b, c, ans1, ans2, ans = 0; int main() { cin >> hx >> hy >> ux >> uy; cin >> n; for (int i = 1; i <= n; i++) { cin >> a >> b >> c; ans1 = a * hx + b * hy + c; ans2 = a * ux + b * uy + c; if (((ans1 > 0) && (ans2 < 0)) || ...
Problem: 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 ...
import java.math.BigInteger; import java.util.*; public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); BigInteger a = in.nextBigInteger(), b = in.nextBigInteger(), c = in.nextBigInteger(), d = in.nextBigInteger(); int n = in.nextInt(); int a...
Problem: 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 ...
line = input().split() x1 = int(line[0]) y1 = int(line[1]) line = input().split() x2 = int(line[0]) y2 = int(line[1]) n = int(input()) ans = 0 for i in range(n): line = input().split() a = int(line[0]) b = int(line[1]) c = int(line[2]) d1 = (a * x1 + b * y1 + c) d2 = (a * x2 + b * y2 + c) if...
Problem: 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 ...
import java.util.*; import java.io.*; import java.math.*; public class a{ static long f(long a,long b,long c,long x,long y){ return a*x+b*y+c; } public static void main( String [] args) throws IOException{ FastScanner sc=new FastScanner(); long x1=sc.nextLong();long y1=sc.nextLong(); long x2=sc.nextLong();lo...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; double cross(pair<double, double> u, pair<double, double> v) { return u.first * v.second - u.second * v.first; } int getSign(double a) { if (fabs(a) < EPS) { return 0; } return a > 0 ? 1 : -1; } pair<double, double> minuss(pair<double, d...
Problem: 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 ...
x,y=map(int,raw_input().split()) a,b=map(int,raw_input().split()) result=0 for i in xrange(0,int(raw_input())): d,r,e=map(int,raw_input().split()) if (d*x+r*y+e)*(d*a+r*b+e)<0: result+=1 print result
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int N = 333; int n; int pos[N]; int main() { int sx, sy, tx, ty, answer = 0; scanf("%d %d %d %d", &sx, &sy, &tx, &ty); scanf("%d", &n); for (int i = 1; i <= n; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); int sign = ((1LL * sx * a + 1LL * sy ...
Problem: 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 ...
import fileinput ### ### # utility func # ### ### dbug = True def stoi(s): return([ int(x) for x in s.split() ]) def pd(s, label=''): global dbug if dbug: header = 'debug:' if label != '': header += ' (%s)\t' % label print header, s ### ### # code follows # ### ### ...
Problem: 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 ...
/** * Created by daria on 24.12.14. */ import java.io.*; import java.util.*; public class A { class Pair { int x, y; Pair(int y, int x) { this.y = y; this.x = x; } } class Triplet { int x, y, z; Triplet(int x, int y, int z) { ...
Problem: 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 ...
#include <bits/stdc++.h> long long sx, sy, ex, ey, n, a, b, c, i, ans, t1, t2; int main() { scanf("%lld%lld%lld%lld%lld", &sx, &sy, &ex, &ey, &n); for (ans = 0, i = 1; i <= n; ++i) { scanf("%lld%lld%lld", &a, &b, &c); t1 = (a * sx + b * sy + c) >= 0 ? 1 : -1; t2 = (a * ex + b * ey + c) > 0 ? 1 : -1; ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long x1, y1, x2, y2; scanf("%I64d%I64d%I64d%I64d", &x1, &y1, &x2, &y2); int n; scanf("%d", &n); int num = 0; for (int i = 0; i < n; i++) { long long a, b, c; scanf("%I64d%I64d%I64d", &a, &b, &c); long long tmp1 = a * x1 + b * y1 + c...
Problem: 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 ...
import java.io.*; import java.math.*; import java.util.*; public class SolutionA{ public static void main(String[] args){ new SolutionA().run(); } int n; int sgn(long x){ if(x < 0) return -1; return 1; } void solve(){ Pair p1 = new Pair(in.nextInt(), in.nextInt()); Pair p2 = new Pair(in.nextInt(), in....
Problem: 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 ...
import java.util.Arrays; import java.util.Scanner; public class MainC { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void...
Problem: 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 ...
import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = Sys...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { long long ans = 0, n; double x1, x2, y1, y2, a, b, c; scanf("%lf %lf", &x1, &y1); scanf("%lf %lf", &x2, &y2); scanf("%I64d", &n); for (int i = 1; i <= n; i++) { scanf("%lf %lf %lf", &a, &b, &c); double d = y2 - y1, e = x1 - x2, f = x2 * y1 -...
Problem: 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 ...
[h,u] = [[int(s) for s in raw_input().split()] for i in xrange(2)] t = 0 n = int(raw_input()) for i in xrange(n): l = [int(s) for s in raw_input().split()] if( (h[0]*l[0] + h[1]*l[1] + l[2])*(u[0]*l[0] + u[1]*l[1] + l[2]) <0): t += 1 print t
Problem: 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 ...
import java.util.Scanner; public class CF284C { private static class Point { double x; double y; public Point(final double x, final double y) { this.x = x; this.y = y; } } public static void main(final String[] args) { Scanner sc = new Scan...
Problem: 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 ...
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) n = int(input()) s = 0 for i in range(n): a, b, c = map(int, input().split()) if ((((a * x1) + (b * y1) + c) * ((a * x2) + (b * y2) + c)) <= 0): s = s + 1 print(s)
Problem: 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 ...
#include <bits/stdc++.h> int main() { long long x1, y1, x2, y2, a, b, c; int n; while (scanf("%I64d%I64d", &x1, &y1) != EOF) { scanf("%I64d%I64d", &x2, &y2); scanf("%d", &n); long long ans = 0; for (int i = 0; i < n; i++) { scanf("%I64d%I64d%I64d", &a, &b, &c); long long num = a * x1 +...
Problem: 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 ...
import java.util.Scanner; /** * http://codeforces.ru/contest/498/problem/A * * @author scorpion@yandex-team on 08.01.15. */ public class Solution498A { public static void main(final String[] args) throws Exception { final Scanner sc = new Scanner(System.in); final int x1 = sc.nextInt(); final int y1...
Problem: 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 ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pradyumn Agrawal coderbond0...
Problem: 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class CrazyTown_CodeForces { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = ne...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; double x1, x2, y1, y2; double a, b, c; cin >> x1 >> y1; cin >> x2 >> y2; cin >> n; int count = 0; double A = y2 - y1; double B = x1 - x2; double C = x2 * y1 - x1 * y2; for (int i = 0; i < n; ++i) { cin >> a >> b >> c; if ((b...
Problem: 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 ...
import java.util.*; public class a { public static void main(String[] args) { Scanner input = new Scanner(System.in); Point a = new Point(input.nextInt(), input.nextInt()), b = new Point(input.nextInt(), input.nextInt()); int n = input.nextInt(), res = 0; Line[] data = new Line[n]; for(int i = 0; i<...
Problem: 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 ...
import fileinput ### ### # utility func # ### ### dbug = True def stoi(s): return([ int(x) for x in s.split() ]) def pd(s, label=''): global dbug if dbug: header = 'debug:' if label != '': header += ' (%s)\t' % label print header, s ### ### # code follows # ### ### ...
Problem: 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 ...
from collections import namedtuple import math Point = namedtuple('Point', ['x', 'y']) Line = namedtuple('Line', ['a', 'b', 'c']) toPoint = lambda x: Point(int(x[0]), int(x[1])) toLine = lambda x: Line(int(x[0]), int(x[1]), int(x[2])) def cppdiv(a, b): if b == 0: return a * math.inf return a / b def paralle...
Problem: 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 ...
import java.io.*; import java.util.*; public class A { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); long x1 = in.nextInt(), y1 = in.nextInt(); long x2 = in.nextInt(), y2 = in.nextInt(); int n = in.nextIn...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long x1, y1; long long x2, y2; cin >> x1 >> y1 >> x2 >> y2; int n; cin >> n; int ans = 0; while (n--) { long long a, b, c; cin >> a >> b >> c; long long t1 = a * x1 + b * y1 + c; long long t2 = a...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; double xs, ys, xf, yf; int n; int main() { ios::sync_with_stdio(false); cin >> xs >> ys >> xf >> yf >> n; int t = 0; for (long long i = 0; i < (n); i++) { double a, b, c; cin >> a >> b >> c; if (a != 0 && b != 0) { bool f, s; if ((-c - xs * a...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; const int N = 1005; int main() { ios::sync_with_stdio(0); cin.tie(0); long long x1, x2, y1, y2, n, ans = 0; cin >> x1 >> y1 >> x2 >> y2; cin >> n; for (int i = 1; i <= n; i++) { long long a, b, c; cin >> a >> b >> c; if ((...
Problem: 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 ...
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.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static ...
Problem: 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 ...
def main(): Hx, Hy = [int(i) for i in input().split()] Ux, Uy = [int(i) for i in input().split()] N = int(input()) qtd = 0 for n in range(N): a, b, c = [int(i) for i in input().split()] if (a*Hx + b*Hy + c)*(a*Ux + b*Uy + c) < 0: qtd+=1 print(qtd) main() # 1510341040937
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; struct Point { double x, y; }; struct Line { double a, b, c; }; int main() { Point start, dest; cin >> start.x >> start.y >> dest.x >> dest.y; if (start.x > dest.x) swap(start, dest); Line line; line.a = start.y - dest.y; line.b = dest.x - start.x; line.c ...