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 | #include <bits/stdc++.h>
int main() {
int n, x1, y1, x2, y2, ans = 0;
scanf("%d%d", &x1, &y1);
scanf("%d%d", &x2, &y2);
scanf("%d", &n);
long long a, b, c;
for (int i = 1; i <= n; i++) {
scanf("%I64d%I64d%I64d", &a, &b, &c);
long long t1 = a * x1 + b * y1 + c;
long long t2 = 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;
long long modulo = 1e9 + 7;
long long mod1 = 998244353;
int main() {
long long i, j, k = 0, a, b, c, x1, y1, x2, y2, p, q, r;
cin >> x1 >> y1 >> x2 >> y2 >> j;
for (i = 0; i < j; i++) {
cin >> a >> b >> c;
p = a * x1 + b * y1 + c;
if (p > 0)
p = 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 | import java.util.*;
public class Codeforces1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
//System.out.print("Enter your home coordinates ");
//String Line =sc.nextLine();
StringTokenizer st =new StringTokenizer(sc.nextLine());
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 | import java.io.*;
import java.util.*;
import java.util.List;
public class Main {
private static StringTokenizer st;
private static BufferedReader br;
public static long MOD = 1000000007;
public static long tenFive = 100000;
public static double EPS = 0.000000001;
public static void print(Objec... | 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 | from fractions import Fraction
def line_equation(pt1, pt2):
return (pt1[1] - pt2[1], pt2[0] - pt1[0],
pt1[0] * pt2[1] - pt1[1] * pt2[0])
def line_intersection(line1, line2):
if line1[0] * line2[1] - line1[1] * line2[0] == 0:
return (10 ** 18, 10 ** 18)
return (Fraction(line1[1] * lin... | 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 n;
long long startX, startY, targetX, targetY, a, b, c, ans;
long long sign(long long x, long long y) { return a * x + b * y + c; }
bool onOppSides() {
long long s = sign(startX, startY);
long long t = sign(targetX, targetY);
return (s < 0 and t > 0) or (s > 0 and... | 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 {
double x, y;
point() { x = y = 0.0; }
point(double _x, double _y) : x(_x), y(_y) {}
};
struct vec {
double x, y;
vec(double _x, double _y) : x(_x), y(_y) {}
};
vec toVector(point a, point b) { return vec(b.x - a.x, b.y - a.y); }
double crossProd(vec... | 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.InputStreamReader;
import java.util.StringTokenizer;
public class C499 {
public static void main(String[] args) throws Exception {
final FastScanner scanner = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
final int srcX = scanner.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>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
long long sign(long long a) {
if (a > 0) return 1;
if (a < 0) return -1;
return 0;
}
int main() {
long long x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
long long res = 0;
for (long long 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.io.BufferedReader;
import java.io.InputStreamReader;
/**
*
* @author bavudaia
*/
public class Town {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String S1[] = br.readLine().split(" ");
Stri... | 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 ans = 0;
long long x2, x3, y2, y3;
cin >> x2 >> y2;
cin >> x3 >> y3;
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
long long a, b, c;
cin >> a >> b >> c;
long long num1 = a * x2 + b * y2 + c;
long long num2 = a * x3 + b * y3 +... | 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(void) {
int N, i, ans = 0;
long long x1, y1, x2, y2;
long long a, b, c;
cin >> x1 >> y1 >> x2 >> y2;
cin >> N;
for ((i) = 0; (i) < (int)(N); (i)++) {
cin >> a >> b >> c;
long long s1 = x1 * a + y1 * b + c;
long long s2 = x2 * a + y2 * b + 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;
int main() {
long long x1, y1, x2, y2, n;
cin >> x1 >> y1;
cin >> x2 >> y2;
cin >> n;
long long a, b, c, ans = 0;
for (long long i = 0; i < n; i++) {
scanf("%lld", &a);
scanf("%lld", &b);
scanf("%lld", &c);
if (((a * x1 + b * y1 + c) > 0 && (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 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @author grozhd
*/
public class Geometry {
static Point home;
static Point uni;
static List<Line> lines;
public static void main(String[] args) {
... | 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);
cin.tie(0);
long long x, y, x2, y2;
cin >> x >> y >> x2 >> y2;
int n;
cin >> n;
int ans = 0;
while (n--) {
long long a, b, c;
cin >> a >> b >> c;
if ((a * x + b * y + 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 | h = map(int,raw_input().split())
u = map(int,raw_input().split())
ans = 0
for i in range(input()):
a = map(int,raw_input().split())
if (a[0]*h[0] + a[1]*h[1] + a[2]) * (a[0]*u[0] + a[1]*u[1] + a[2]) < 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 | #include <bits/stdc++.h>
using namespace std;
long long a, b, c;
int line(long long x, long long y) {
long long ret = a * 1LL * x + b * 1LL * y + c * 1LL;
if (ret < 0)
return -1;
else
return 1;
}
int main() {
int x1, y1, x2, y2;
scanf("%I64d %I64d", &x1, &y1);
scanf("%I64d %I64d", &x2, &y2);
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 | m1,m2=map(int,raw_input().split())
u1,u2=map(int,raw_input().split())
n=input()
ans=0
for i in range(n):
a,b,c=map(int,raw_input().split())
if (a*m1+b*m2+c)*(a*u1+b*u2+c)<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 | #include <bits/stdc++.h>
int main() {
long long x1, y1, x2, y2;
long long n, a, b, c, i;
long long tmp1, tmp2;
int res = 0;
scanf("%I64d %I64d", &x1, &y1);
scanf("%I64d %I64d", &x2, &y2);
scanf("%I64d", &n);
for (i = 0; i < n; ++i) {
scanf("%I64d %I64d %I64d", &a, &b, &c);
tmp1 = a * x1 + b * y1... | 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 Main1{
public static Reader sc = new Reader();
//public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static double e = Math.pow(10, -8);
public static void main(String[] args) throws IOException{
double x = 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;
double x, y, p, q;
int n;
int a[1001][2], ans = 0;
int main() {
double A, b, c;
scanf("%lf %lf", &x, &y);
scanf("%lf %lf", &p, &q);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%lf %lf %lf", &A, &b, &c);
int tmpx = 0, tmpy = 0;
if (A * x + 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.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{ public static void main (String[] args)throws IOException {
try{
//BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
Scanner sc ... | 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;
public class Main {
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 };
final... | 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 | ans,v1 = 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
| 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
import fileinput
first = stdin.readline()[:-1].split()
sec = stdin.readline()[:-1].split()
home = map(int, first)
uni = map(int, sec)
lineCount = int(stdin.readline()[:-1])
lines = []
for i in xrange(lineCount):
l = stdin.readline()[:-1].split()
lines.append(map(int, l))
def getAnyPoint(... | 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.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
* @author Igor Kraskevich
*/
public 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 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CR284_crazy_town {
public static void main(String... args) throws IOException {
MyScanner sc = new MyScanner();
int x1 = sc.nextInt();
int y1 = sc.ne... | 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 | x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
n = int(raw_input())
res = 0
for i in xrange(n):
a, b, c = map(int, raw_input().split())
d1 = a*x1 + b*y1 + c
d2 = a*x2 + b*y2 + c
if (d1 < 0 and d2 > 0) or (d1 > 0 and d2 < 0):
res += 1
print res | 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 | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(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;
template <class T>
inline T bigmod(T p, T e, T M) {
long long ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1) ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
if (b == 0) return a;
return gcd(b, a % 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 | #include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
int x1, y1, x2, y2, res = 0;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
int n;
scanf("%d", &n);
for (int i = 0; i < (int)(n); ++i) {
long long a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
long long t1 = a * x1 + 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 | // package CF;
import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws Excep... | 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 | //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 | import java.util.*;
public class crazy {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
long x1=cin.nextLong();
long y1=cin.nextLong();
long x2=cin.nextLong();
long y2=cin.nextLong();
int n=cin.nextInt();
long []a=ne... | 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 | hx,hy=[int(x) for x in raw_input().split()]
ux,uy=[int(x) for x in raw_input().split()]
n=int(raw_input())
count=0
for i in range(n):
a,b,c=[int(x) for x in raw_input().split()]
if ((a*hx+ b*hy + c >0) and (a*ux + b*uy +c < 0)) or ((a*hx+b*hy+c <0) and (a*ux+b*uy+c > 0)):
count+=1
print count
| 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 | def onLine(a,b,c,x,y):
return a*x+b*y+c
def intrs(x1,y1,x2,y2,a,b,c):
if onLine(a,b,c,x1,y1)*onLine(a,b,c,x2,y2)<0:
return True
return False
x1,y1=map(int,raw_input().split())
x2,y2=map(int,raw_input().split())
n=int(raw_input())
ans=0
for i in range(n):
a,b,c=map(int,raw_input().split())
... | 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 | /*
* Remember a 7.0 student can know more than a 10.0 student.
* Grades don't determine intelligence, they test obedience.
* I Never Give Up.
*/
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.text.*;
import static java.lang.System.out;
import static java.util.Arrays.*;
import 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 |
import java.util.*;
import java.io.*;
public class A
{
public static void main(String[] args) throws Exception
{
PrintWriter out = new PrintWriter(System.out);
new A(new FastScanner(System.in), out);
out.close();
}
public A(FastScanner in, PrintWriter out)
{
int[] a = new int[]... | 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.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
/**
* @author Don Li
*/
public class CrazyTown {
void solve() {
long x1 = in.nextInt(), y1 = in.nextInt();
long x2 = in.nextInt(), y2 = in.nex... | 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 = 1000000007, N = 100000, M = 1000;
struct node {
long long a, b, c;
} a[400];
long long n, A, B, C, ans = 0;
double x, y, x2, y2;
int main() {
cin >> x >> y >> x2 >> y2 >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].a >> a[i].b >> a[i].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 | ans = 0
read_line = lambda: [int(i) for i in input().split()]
x0, y0 = read_line()
x1, y1 = read_line()
n = int(input())
for i in range(n):
a, b, c = read_line()
ans += (a * x0 + b * y0 + c) * (a * x1 + b * y1 + c) < 0
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 | #include <bits/stdc++.h>
using namespace std;
long long p, q, x, y, n, sum;
int main() {
cin >> p >> q >> x >> y >> n;
for (int i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
long long first = (a * p) + (b * q) + c;
long long last = (a * x) + (b * y) + c;
if ((first < 0 && last > 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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out)... | 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;
bool sep(long long a, long long b, long long c, long long hx, long long hy,
long long ux, long long uy) {
long long ans1 = a * hx + b * hy + c;
long long ans2 = a * ux + b * uy + c;
if (ans1 > 0 && ans2 < 0) return true;
if (ans1 < 0 && ans2 > 0) return tru... | 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>
long long gcd(long long a, long long b) {
while (a && b) {
if (a > b)
a %= b;
else
b %= a;
}
return a + b;
}
long long lcm(long long a, long long b) { return (((a * b) / gcd(a, b))); }
int phi(int n) {
int result = n;
for (long long i = 2; i * i <= n; i++) {
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1, x2, y2, n;
scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &n);
int cnt = 0;
for (int i = 0; i < n; i++) {
double a, b, c;
scanf("%lf%lf%lf", &a, &b, &c);
double t1 = a * x1 + b * y1 + c;
double 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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.StringTokenizer;
public class Main {
static DecimalFormat formatter = new DecimalFormat("#0.00");
static final double E... | 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>
const long long INF = 1e9;
const long long lINF = 1e18;
using namespace std;
int n;
long long xx1, yy1, xx2, yy2;
int main() {
cin >> xx1 >> yy1 >> xx2 >> yy2;
cin >> n;
int ans = 0;
for (int i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
if (a * xx1 + b * yy1 +... | 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;
struct reta {
int a, b, c;
} a, b, v[maxn];
int n;
int main() {
cin >> a.a >> a.b;
cin >> b.a >> b.b;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> v[i].a >> v[i].b >> v[i].c;
}
int resp = 0;
for (int i = 1; i <= n; ++i) {
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.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;
import java.util.Arrays;
import java.util.ArrayList;
/**
* Built using CHelper plug-in
* Actual solution ... | 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.math.*;
import java.util.*;
import java.util.concurrent.*;
public class P498A {
long det(long a1, long b1, long a2, long b2) {
return (a1 * b2 - a2 * b1);
}
@SuppressWarnings("unchecked")
public void run() throws Exception {
long x1 = nextLong();
long y1 = 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 main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long xh, yh, xs, ys, n;
cin >> xh >> yh >> xs >> ys >> n;
int ans = 0;
for (int i = 0; i < n; ++i) {
long long a, b, c;
cin >> a >> b >> c;
ans += ((a * xs + b * ys + c > 0) ^ (a * xh + 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 | #include <bits/stdc++.h>
using namespace std;
int sgn(long long v) { return v > 0 ? 1 : 0; }
int main(void) {
long long p, q, r, s;
cin >> p >> q >> r >> s;
int n;
int res = 0;
cin >> n;
for (int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b >> c;
long long temp1 = (a * p + b * q + c);
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 | x1, y1 = [int(x) for x in input().split()]
x2, y2 = [int(x) for x in input().split()]
n = int(input())
ans = 0
for i in range(n):
a, b, c = [int(x) for x in input().split()]
p = a*x1 + b*y1 + c < 0
q = a*x2 + b*y2 + c < 0
if p ^ q == True:
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.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x = in.nextInt();
int y = in.nextInt();
int xx = in.nextInt();
int yy = in.nextInt();
int n = in.nextInt();
int res = 0;
while (n-->0) {
int a = in.nex... | 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.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.ut... | 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.*;
import java.math.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
//--------------->>>>IF YOU ARE HERE FOR QUICKSORT HACK THEN SORRY NO HACK FOR YOU<<<-------------------
public class a{
static long[] count... | 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 | R=lambda:map(int,raw_input().split())
Rs=lambda:raw_input().split()
x1,y1=R()
x2,y2=R()
n=input()
ans=0
for i in range(n):
a,b,c=R()
if (a*x1+b*y1+c)*(a*x2+b*y2+c)<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.InputStreamReader;
import java.util.StringTokenizer;
public class Problem498A {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringToken... | 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.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author thnkndblv
*/
public class Main {
public static void main(String[] args) {
InputStream 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;
int main() {
pair<int, int> u, v;
int n, ans = 0;
long long a, b, c, p, q;
scanf("%d%d%d%d", &u.first, &u.second, &v.first, &v.second);
scanf("%d", &n);
while (n--) {
scanf("%lld%lld%lld", &a, &b, &c);
p = a * u.first + b * u.second + c;
q = a * v.fi... | 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.awt.Point;
public class Main {
private static final java.util.Scanner in = new java.util.Scanner(System.in);
public static void main(String[] args) {
Point s = new Point(in.nextInt(),in.nextInt());
Point t = new Point(in.nextInt(),in.nextInt());
final int n = in.nextInt();
long ans = 0;
Seg... | 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;
double x1, y, x2, y2;
int judge1(double a, double b, double c) {
double tmp;
if (b != 0) {
tmp = (-c - a * x1) / b;
if (tmp > y)
return 1;
else
return -1;
} else {
if (x1 < (-c / a))
return 1;
else
return -1;
}
}
int judge... | 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 | a1, b1 = map(int, raw_input().split())
a2, b2 = map(int, raw_input().split())
n = input()
kq = 0
for i in range(n):
a, b, c = map(int, raw_input().split())
k1 = a*a1 + b*b1 + c
k2 = a*a2 + b*b2 + c
kq += (k1*k2 < 0)
print kq | 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.util.*;
public class maximus {
public static void main(String [] args){
Scanner in=new Scanner(System.in);
double inf=1e9;
double slope=0;
long x=in.nextInt();
long y=in.nextInt();
long x1=in.nextInt();
long y1=in.nextInt();
int n=in.nextInt();
int ans=0;
for(int i=0;i<n;i++){
long a=in.nextInt();
long b=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;
int main() {
int x, y, x2, y2;
cin >> x >> y >> x2 >> y2;
int n;
cin >> n;
long long a, b, c;
int ans = 0;
long long h, hh;
for (int i = 0; i < n; ++i) {
cin >> a >> b >> c;
h = a * x + b * y + c;
hh = a * x2 + b * y2 + c;
if ((h > 0 && hh < ... | 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 RCC {
java.util.Scanner in;
static PrintWriter out;
static class Line {
long a;
long b;
long c;
Line(Scanner in) {
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
}
boolean intersects(Segment seg) {
long s1 = a * seg.a.x + 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;
pair<long long, long long> p1, p2;
int n;
int ans;
int main() {
scanf("%lld %lld", &p1.first, &p1.second);
scanf("%lld %lld", &p2.first, &p2.second);
scanf("%d", &n);
long long a, b, c;
for (int i = 0; i < n; i++) {
scanf("%lld %lld %lld", &a, &b, &c);
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;
int main() {
long long int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
long long int n, ct = 0, a, b, c;
cin >> n;
while (n--) {
cin >> a >> b >> c;
if (((a * x1) + (b * y1) + c) > 0 && ((a * x2) + (b * y2) + c) < 0)
ct++;
else if (((a * x1) + (... | 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 CF;
import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) throws Excep... | 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;
template <class T>
class POINT {
public:
T P[2];
POINT() {}
POINT(T x, T y) { P[0] = x, P[1] = y; }
T operator*(const POINT &a) {
return a.P[0] * this->P[0] + a.P[1] * this->P[1];
}
POINT operator-(const POINT &b) {
return POINT(this->P[0] - b.P[0], thi... | 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 string INPUT_FILE = "input.txt";
const string OUTPUT_FILE = "output.txt";
inline bool IS_UPPERCH(char C) { return C >= 'A' && C <= 'Z'; }
inline bool IS_LOWERCH(char C) { return C >= 'a' && C <= 'z'; }
inline bool IS_LETTERCH(char C) { return IS_UPPERCH(C) || IS_LOWER... | 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;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.writ... | 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 solve(x1, y1, x2, y2, lines):
cnt = 0
for a, b, c in lines:
r1 = a*x1+b*y1+c
r2 = a*x2+b*y2+c
if r1*r2 < 0:
cnt += 1
return cnt
R = lambda: map(int, raw_input().split())
x1, y1 = R()
x2, y2 = R()
n = int(raw_input())
lines = [R() for i in range(n)]
print solve(x1, y1... | 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;
struct node {};
long long A[1000005], B[1000005], C[1000005];
int main() {
long long i, j, k, l, m, n, x, y, z, a, b, c, d, t, x1, x2, y1, y2;
string str;
struct node s;
cin >> x1 >> y1;
cin >> x2 >> y2;
cin >> n;
long long cnt = 0;
for (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 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &a, const T &b) {
if (a > b) a = b;
}
template <class T>
inline void amax(T &a, const T &b) {
if (a < b) a = b;
}
long long HX, HY, UX, UY;
int N;
int sgn(long long n) {
if (n < 0) return -1;
if (n > 0) return 1;
return 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, x2, y1, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
int n, ans = 0;
scanf("%d", &n);
while (n--) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
long long p1 = 0, p2 = 0;
p1 = 1ll * (1ll * a * x1 + 1ll * b * y1 + 1ll * c);
p2 = ... | 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 | hx, hy = map(int, raw_input().split())
ux, uy = map(int, raw_input().split())
n = int(raw_input())
k = 0
for i in xrange(n):
a, b, c = map(int, raw_input().split())
A = a*hx + b*hy + c < 0
B = a*ux + b*uy + c > 0
C = a*hx + b*hy + c > 0
D = a*ux + b*uy + c < 0
k += [0, 1][(A and B) or (C and D)]
print k | 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, input().split())
x2, y2 = map(int, input().split())
val = 0
for i in range(int(input())):
a, b, c = map(int, input().split())
val += (a * x1 + b * y1 + c) * (a * x2 + b * y2 + c) < 0
print(val) | 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;
struct Point {
double x;
double y;
};
int main() {
Point p1, p2;
int i, ans = 0;
double n, a, b, c;
cin >> p1.x >> p1.y >> p2.x >> p2.y >> n;
for (i = int(0); i < int(n); i++) {
cin >> a >> b >> c;
if ((a * p1.x + b * p1.y + c) * (a * p2.x + b * p2.y +... | 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 | home = map(int, raw_input().split())
colg = map(int, raw_input().split())
def cost(a, b, c, x):
return a*x[0] + b*x[1] + c > 0
n = input()
ans = 0
for ii in range(n):
a, b, c = map(int, raw_input().split())
if cost(a,b,c, home) != cost(a,b,c, colg):
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 | #include <bits/stdc++.h>
using namespace std;
long long fast_exp(long long base, long long power) {
long long ans = 1;
while (power) {
if (power & 1) ans = (ans * base) % 1000000007ll;
base = (base * base) % 1000000007ll;
power = power >> 1;
}
return ans % 1000000007ll;
}
long long modInv(long 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 N, xh, yh, xu, yu;
int A[303], B[303], C[303];
set<vector<bool> > s;
double eval(int i, double x, double y) { return A[i] * x + B[i] * y + C[i]; }
bool test(int i, vector<bool> &v) {
double ax, ay, bx, by;
if (B[i] == 0) {
ax = bx = -C[i] / A[i];
ay = -20000... | 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(_) for _ in input().split()]
x2, y2 = [int(_) for _ in input().split()]
n = int(input())
ans = 0
for i in range(n):
a, b, c = [int(_) for _ in input().split()]
zy1 = a * x1 + b * y1 + c
zy2 = a * x2 + b * y2 + c
if (zy1 > 0 and zy2 < 0) or (zy1 < 0 and zy2 > 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 | #include <bits/stdc++.h>
constexpr bool LOG = false;
using namespace std;
using vi = vector<int>;
using ll = long long;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;
void Log() {
if (LOG) cerr << "\n";
}
template <class T, class... S>
void Log(T t, S... s) {
if (LOG) cerr << t << "\t", Log(s...);
}
st... | 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 {
double x, y;
Point(double x = 0, double y = 0) : x(x), y(y) {}
};
Point operator-(Point A, Point B) { return Point(A.x - B.x, A.y - B.y); }
const double eps = 1e-10;
int dcmp(double x) {
if (fabs(x) < eps)
return 0;
else
return x < 0 ? -1 : 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 | #include <bits/stdc++.h>
using namespace std;
template <class T>
void makemax(T& a, const T& b) {
if (a < b) a = b;
}
template <class T>
void makemin(T& a, const T& b) {
if (a > b) a = b;
}
int main() {
int xh, yh, xu, yu;
scanf("%d%d", &xh, &yh);
scanf("%d%d", &xu, &yu);
int n;
scanf("%d", &n);
int cnt... | 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() {
double x1, y1, x2, y2, a, b, c, m;
while (cin >> x1 >> y1) {
cin >> x2 >> y2;
cin >> m;
int ans = 0;
for (int i = 0; i < m; i++) {
cin >> a >> b >> c;
double p1 = a * x1 + b * y1 + c;
double p2 = 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 | #!/usr/bin/env python3
x1, y1 = (int(x) for x in input().split())
x2, y2 = (int(x) for x in input().split())
n = int(input())
ans = 0
for i in range(n):
a, b, c = (int(x) for x in input().split())
point1 = a*x1 + b*y1 + c
point2 = a*x2 + b*y2 + c
if point1 * point2 < 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
double x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
double x[n], y[n], c[n];
int ans = 0;
for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> c[i];
for (int i = 0; i < n; i++) {
double a, b;
a = x[i] * x1 + y[i] * y1 + 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;
template <class T>
inline T bigmod(T p, T e, T M) {
long long int ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1) ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
if (b == 0) return a;
return gcd(b, a % 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 | x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
n = int(raw_input())
ans = 0
for i in xrange(n):
a, b, c = map(int, raw_input().split())
p1, p2 = 0, 0
p1 = a*x1 + b*y1 + c
p2 = a*x2 + b*y2 + c
if p1>0 and p2<0:
ans+=1
if p2>0 and p1<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.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Vector start = new Vector(sc.nextDouble(),sc.nextDouble());
Vector end = new Vector(sc.nextDouble(),sc.nextDouble());
Line path = new Line(start,end);
int N = sc.nextInt();
int ans = 0... | 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 | x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
n = int(input())
lines = []
for _ in range(n):
a, b, c = map(int, input().split())
lines.append((a, b, c))
ans = 0
for a, b, c in lines:
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 | import java.util.Scanner;
public class CrazyTown{
public static void main( String args[] ){
double[][] roads;
double[][] intersects;
int indexInter[];
double[] home;
double[] uni;
double[] road;
int countInter;
int count;
int roadNum;
int countIndexInter;
Scanner scan ... | 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 compute(a,b,c,x,y):
if (a*x + b*y + c)<0: return -1
return 1
x1,y1 = map(int, raw_input().split())
x2,y2 = map(int, raw_input().split())
n = int(raw_input())
answer = 0
for i in range(n):
a,b,c = map(int,raw_input().split())
if compute(a,b,c,x1,y1)!=compute(a,b,c,x2,y2): answer +=1
print answer
| 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 | //package graph_related;
import java.util.*;
import java.math.*;
public class Dijkstra {
public static Map<String, String> ftos = new HashMap<String, String>();
public static Map<String, String> stof = new HashMap<String, String>();
public static boolean[] taken;
public static void main(String[] args)
{
Scann... | 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 maxn = int(1e5) + 123;
const int inf = 1 << 30;
const int mod = int(1e9) + 7;
long long xa, ya, xb, yb, a, b, c, p, q;
int ans, n;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> xa >> ya >> xb >> yb;
cin >> n;
for (int i = 1; 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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
public class P499C {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
PrintWriter pw = new PrintWriter(System.out, true);
NewReader s... | 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 | x1,y1=[int(i) for i in input().split()]
x2,y2=[int(i) for i in input().split()]
n=int(input())
r=0
for i in range(n):
a,b,c = [int(i) for i in input().split()]
if (a*x1+b*y1+c)*(a*x2+b*y2+c)<0:
r+=1
print(r)
| PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.