Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
n = int(input())
arr = []
for _ in range(n):
a, b, c = map(int, input().split())
arr.append((a,b,c))
res = 0
for i in arr:
a, b, c = i
if(b != 0):
y00 = -c/b
y01 = -(a+c)/b
s1 = x1*(y01-y00)-(y1-y00)
s2 = x2*(y01-y00)-(y2-y00)
if(s1<0<s... | PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 |
# Crazy Town (2 points on same/opposite side of a line)
# input
k1 = list(map(int, input().split()));
(x1,y1) = (k1[0],k1[1])
k2 = list(map(int, input().split()));
(x2,y2) = (k2[0],k2[1])
t = int(input())
d = 0;
for i in range(t):
k3 = list(map(int, input().split()));
(a,b,c) = (k3[0],k3[1],k3[2])
#
... | 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 | xh, yh = list(map(int, input().split()))
xu, yu = list(map(int, input().split()))
n = int(input())
res = 0
for x in range(n):
a, b, c = list(map(int, input().split()))
if (a*xh + b*yh + c)*(a*xu + b*yu + c ) < 0:
res += 1
print(res) | 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 linear(int a, int b, int c, int x, int y) {
return 1ll * a * x + 1ll * b * y + 1ll * c;
}
int main() {
int xa, ya, xb, yb, ans = 0, n;
scanf("%d %d %d %d", &xa, &ya, &xb, &yb);
scanf("%d", &n);
while (n--) {
int a, b, c;
scanf("%d %d %d", &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 | import java.io.*;
import java.util.*;
public class Main {
static PrintWriter pw;
static Scanner sc;
static long ceildiv(long x, long y) { return y==0?inf:(x+y-1)/y; }
static int mod(long x, int m) { return (int)((x%m+m)%m); }
static void put(TreeMap<Integer, Integer> map, Integer p){if(map.contains... | 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 x1, yy1, x2, y2;
int result;
void init() { scanf("%d%d%d%d", &x1, &yy1, &x2, &y2); }
long long calc(int a, int b, int c, int x, int y) {
long long t1, t2, t;
t1 = a;
t1 *= x;
t2 = b;
t2 *= y;
return t1 + t2 + c;
}
void work() {
int n;
int a, b, c;
long... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | a1, b1 = map(int, raw_input().split(' '))
a2, b2 = map(int, raw_input().split(' '))
n = input()
count = 0
for i in range(n):
a, b, c = map(int, raw_input().split(' '))
t1 = a1 * a + b1 * b + c
t2 = a2 * a + b2 * b + c
if (t1 > 0 and t2 < 0) or (t1 < 0 and t2 > 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 | #include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
if (a > b) {
return a;
} else {
return b;
}
}
long long min(long long a, long long b) {
if (a < b) {
return a;
} else {
return b;
}
}
struct P {
double x, y;
P() {}
P(double x, double y) : x(x), y(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 | #include <bits/stdc++.h>
using namespace std;
const int N = 300 + 10;
int a, b, c, n, sx, sy, tx, ty;
long long calc(int x, int y) { return 1ll * a * x + 1ll * b * y + 1ll * c; }
int main() {
ios::sync_with_stdio(0);
cin >> sx >> sy >> tx >> ty >> n;
int ans = 0;
for (int i = 0; i < n; i++) {
cin >> 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 n, k, m;
int X1, X2, Y1, Y2;
struct ac {
int a, b, c;
};
void input() {
int i, ans = 0;
long long a, b, c;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%lld %lld %lld", &a, &b, &c);
long long x = (long long)a * X1 + (long long)b * Y1 + (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 | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.*;
import java.util.*;
public class CF284C {
static long x1, y1, x2, y2;
static int result;
public static void main(String[] args) throws Exception {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = 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;
int main() {
long long x1, y1, x2, y2, n, a, b, c, step = 0, i;
cin >> x1 >> y1 >> x2 >> y2 >> n;
for (i = 0; i < n; i++) {
cin >> a >> b >> c;
if ((a * x1 + b * y1 + c > 0) && (a * x2 + b * y2 + c < 0)) step++;
if ((a * x1 + b * y1 + c < 0) && (a * x2 + b... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.*;
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 StringTokenizer(reader.readLine());
int xh = Integer.parseInt(tokenize... | 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 = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
struct Point {
int x, y;
Point() {}
Point(int x, int y) : x(x), y(y) {}
void read() { scanf("%d%d", &x, &y); }
} A, B;
struct Segment {
Point p, q;
Segment(... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long a, b, c;
int n;
long long X1, Y1, X2, Y2;
long long sign(long long a) {
if (a > 0) return 1;
if (a < 0) return -1;
return 0;
}
int main() {
cin >> X1 >> Y1 >> X2 >> Y2;
cin >> n;
int ans = 0;
for (int i = 0; i < n; ++i) {
cin >> a >> 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;
struct point {
long long x, y;
};
struct line {
long long a, b, c;
};
const int MAXN = 300;
int n, ans;
point a, b;
line l[MAXN + 9];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cin >> a.x >> a.y >> b.x >> b.y >> n;
ans = 0;
for (int i = 1; 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 long long hx, hy, ux, uy, n, a, b, c, val1, val2, count = 0;
cin >> hx >> hy;
cin >> ux >> uy;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a >> b >> c;
val1 = a * hx + b * hy + c;
val2 = a * ux + b * uy + c;
if (val1 > 0 && val2... | 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;
/**
* Created by hama_du
*/
public class ProblemA {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter... | 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.math.*;
public class Main {
static BufferedReader in;
static PrintWriter out;
static StringTokenizer tok;
static void solve() throws Exception {
int x1 = nextInt();
int y1 = nextInt();
int x2 = nextInt();
int y... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
namespace qwq {
inline long long read(long long &o) {
o = 0;
long long w = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') w = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
o = (o << 3) + (o << 1) + (c ^ 48);
c = getchar()... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.util.Scanner;
public class A498 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int x1 = input.nextInt();
int y1 = input.nextInt();
int x2 = input.nextInt();
int y2 = input.nextInt();
int N = input.nextInt();
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;
long long bgm(long long a, long long b, long long m) {
a %= m;
long long rem = 1;
while (b) {
if (b & 1) rem = (rem * a) % m;
a = (a * a) % m;
b >>= 1;
}
return rem;
}
long long inv(long long a, long long mod) { return bgm(a, mod - 2, mod); }
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 | homex,homey=map(int, raw_input().split())
unix,uniy=map(int, raw_input().split())
n=int(raw_input())
lines=0
for i in range(n):
a,b,c=map(int, raw_input().split())
if((a*homex + b*homey + c > 0) and (a*unix + b*uniy + c < 0)):
lines+=1
elif((a*homex + b*homey + c < 0) and (a*unix + b*uniy + c > 0)):
lines+=1
pri... | 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(float, input().split())
x2, y2 = map(float, 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)
| PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public stat... | 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 | // practice with rainboy
import java.io.*;
import java.util.*;
public class CF498A extends PrintWriter {
CF498A() { super(System.out, true); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF498A o = new CF498A(); o.main(); o.flush();
}
void main() {
int x1 = sc.nextInt();
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 | #include <bits/stdc++.h>
using namespace std;
const int N = int(1e5) + 10;
const int K = 11;
const int MOD = int(1e9) + 7;
const int INF = int(2e9) + 5;
const long long INF64 = 1e18;
void Solve() {
long long x1, y1;
cin >> x1 >> y1;
long long x2, y2;
cin >> x2 >> y2;
int cnt = 0;
int n;
cin >> n;
for (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 |
def side(x, y, a, b, c):
return a*x + b*y + c > 0
xA, yA = map(int, raw_input().split())
xB, yB = map(int, raw_input().split())
numSteps = 0
for _ in xrange(input()):
a, b, c = map(int, raw_input().split())
if side(xA, yA, a, b, c) != side(xB, yB, a, b, c):
numSteps += 1
print numSteps
| 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.*;
public class scratch6 {
public static void main (String [] args)throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader (System.in));
PrintWriter pw=new PrintWriter (new OutputStreamWriter (System.out));
String []S=br.readLine().split(" ");//first p... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
double hx, hy, ux, uy;
int n, steps = 0;
cin >> hx >> hy >> ux >> uy >> n;
while (n--) {
double a, b, c;
cin >> a >> b >> c;
steps += int((a * hx + b * hy + c) * (a * ux + b * uy + c) < 0);
}
cout << steps;
return 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 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline T min(T &a, T &b) {
return a < b ? a : b;
}
template <class T>
inline T max(T &a, T &b) {
return a > b ? a : b;
}
template <class T>
void read(T &x) {
char ch;
while ((ch = getchar()) && !(ch >= '0' && ch <= '9'))
;
x = ch - '0';
wh... | 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() {
std::ios::sync_with_stdio(false);
int n, cnt = 0;
long long x1, y1, x2, y2, x3, y3, c;
cin >> x1 >> y1;
cin >> x2 >> y2;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x3 >> y3 >> c;
cnt += (x1 * x3 + y1 * y3 + c < 0 && x2 * x3 + y2 * 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 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class Main {
public static void mai... | 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(false);
cin.tie(0);
cout.tie(0);
long long x1, y1, x2, y2, n, ai, bi, ci, ans = 0;
cin >> x1 >> y1 >> x2 >> y2 >> n;
for (int i = 0; i < n; i++) {
cin >> ai >> bi >> ci;
long long f1 = ai * x1 + bi * y1 + ci;
lo... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long inf64 = 1e18;
const long long MOD = inf + 7;
const long double PI = acos(-1.0);
int32_t main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
;
long long x[2], y[2];
cin >> x[0] >> y[0];
cin >> x[1] >> y[1];
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 | x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
a1=y1-y2
b1=x2-x1
c1=x2*(y2-y1)-y2*(x2-x1)
def intersect(a2,b2,c2):
global a1,b1,c1,x1,y1,x2,y2
if(a1*b2==a2*b1):
return False
x=(b1*c2-b2*c1)/(a1*b2-b1*a2)
y=(a1*c2-c1*a2)/(b1*a2-a1*b2)
if(min(x... | 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() {
ios_base::sync_with_stdio(0);
long long n, i, m, x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
long long ans = 0;
cin >> n;
long long a, b, c;
for (i = 0; i < n; i++) {
cin >> a >> b >> c;
if ((a * x1 + b * y1 + c < 0 && 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 a, b, c;
int main() {
int n, i, ans = 0;
long long r1, r2, c1, c2, t1, t2;
cin >> r1 >> c1 >> r2 >> c2;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> a >> b >> c;
t1 = (r1 * a + c1 * b + c);
t2 = (r2 * a + c2 * b + c);
if (t1 > 0 && t2 < 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.*;
import java.util.*;
public class CF284C
{
static int ans=0;
static long x1,y1,x2,y2;
public static void solver(long a,long b,long c)
{
long x=a*x1+b*y1+c,y=a*x2+b*y2+c;
if((x<0l && y>0l) || (x>0l && y<0l))
ans++;
}
public static void main(String args[])
{
InputReader in = new InputRead... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import sys
#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
def sign(a, b, c, x, y):
value = a * x + b * y + c
if value < 0:
return -1
if value == 0:
return 0
return 1
n, ans = int(input()), 0
for i in range(n):
... | PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main{
final boolean isFileIO = false;
BufferedReader in;
PrintWriter out;
StringTokenizer st = new StringTokenizer("");
String delim = " ";
public static void main(String[] args) throws IOException {
Main ... | 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;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long i, j, k = 0, n, a, b, t = 1, m, l = 0, y, c, ans, count1, countc,
x1, x2, y1, y2, first, second;
while (t--) {
cin >> x1 >> y1 >> x2 >> y2;
cin >> ... | 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 N = 1e5 + 7;
long long power(long long a, long long b) {
long long res = 1;
while (b) {
if (b & 1) res = res * a;
res %= 1000000007;
a = (a * a) % 1000000007;
b /= 2;
}
return res;
}
int a[101], b[101];
struct node {
int req;
int dep;
}... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.util.*;
import java.io.*;
public class Main{
BufferedReader in;
StringTokenizer str = null;
PrintWriter out;
private String next() throws Exception{
while (str == null || !str.hasMoreElements())
str = new StringTokenizer(in.readLine());
return str.nextToken();
}
... | 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 MAX = 1e5 + 5;
const long long INF = 1e9 + 9;
const long long MOD = 1000000007;
long long a[500], b[500], c[500];
long long x1_, y1_;
long long x2_, y2_;
bool intersect(int i) {
long long q, w;
q = a[i] * x1_ + b[i] * y1_ + c[i];
w = a[i] * x2_ + b[i] * y2_ ... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1;
int x2, y2;
int a, b, c;
int n;
cin >> x1 >> y1;
cin >> x2 >> y2;
cin >> n;
int result = 0;
for (int i = 0; i < n; i++) {
int x, y;
int y12, y22;
cin >> a >> b >> c;
if (b == 0) {
x = (-1.0 * c / 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 | #include <bits/stdc++.h>
using namespace std;
struct P {
double x;
double y;
P(double x, double y) : x(x), y(y) {}
P() {}
bool operator<(P other) const {
if (fabs(x - other.x) > 1e-6) {
return x < other.x;
} else {
return y < other.y;
}
}
bool operator==(P other) const {
return... | 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 AB {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x1 = in.nextInt();
int y1 = in.nextInt();
int x2 = in.nextInt();
int y2 = in.nextInt();
int n = in.nextInt();
int A = 0;
for (int i... | 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())
d = [[int(i) for i in input().split()] for j in range(n)]
count = 0
if x1 != x2:
k = (y2 - y1) / (x2 - x1)
b = (y1 * x2 - y2 * x1) / (x2 - x1)
for i in range(n):
if -1 * d[i][0] != d[i][1] * k:
x3 = -1... | PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.PrintStream;
import java.util.Scanner;
public class C {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintStream out = System.out;
long xH = in.nextLong(), yH = in.nextLong();
long xU = in.nextLong(), yU = in.nextLong();
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.*;
import java.util.*;
public class c284{
public static void main(String[] args) {
MyScanner obj = new MyScanner();
int x1=obj.nextInt();
int y1=obj.nextInt();
int x2=obj.nextInt();
int y2=obj.nextInt();
int n=obj.nextInt();
long l[][]=new long[n][3];
lo... | 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 que_b;
import java.io.*;
import java.util.*;
import java.math.*;
public class utkarsh {
InputStream is;
PrintWriter out;
long mod = (long) (1e9 + 7);
boolean SHOW_TIME;
void solve() {
//Enter code here utkarsh
//SHOW_TIME = true;
long x1 = nl(), y1 = n... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.Buffere... | 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.zip.ZipEntry;
import java.math.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Input in = new Input(inputStream);
PrintWriter out = new... | 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;
public class C {
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
out = n... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.util.*;
import java.io.*;
import java.math.*;
public class Euler {
public static void main(String[] args){
FastReader in = new FastReader();
PrintWriter o = new PrintWriter(System.out);
double x1 = in.nextInt();
double y1 = in.nextInt();
double x2 = in.nextInt();
double y2 = in.next... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x, y;
long long x1, y1;
scanf("%lld%lld%lld%lld", &x, &y, &x1, &y1);
int n;
scanf("%d", &n);
long long cnt = 0;
while (n--) {
long long a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if (a * x + b * y + c > 0) {
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 | #include <bits/stdc++.h>
using namespace std;
bool zero(double x) { return fabs(x) <= 1e-8; }
int sign(double x) {
if (zero(x)) return 0;
if (x > 0) return 1;
return -1;
}
struct point {
double x, y;
double tht;
point() {}
point(double xx, double yy) {
x = xx;
y = yy;
}
void output() { printf(... | 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 gcd(long long a, long long b) {
while (b ^= a ^= b ^= a %= b)
;
return a;
}
const int maxn = 2e5 + 9;
const int mod = 1e9 + 7;
double x1, x2, y2, y11;
bool ch(double a, double b, double c) {
double k = a * x1 + b * y11 + c;
double kk = a * x2 + b * y2 ... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
void amir(int x1, int y1, int x2, int y2) {
if (y1 < y2) swap(y1, y2);
int ans = 0;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a, b, c;
cin >> a >> b >> c;
if (b == 0) continue;
double tmp = (-1) * (x1 * a + c) / 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 sys
x1, y1 = map(int,sys.stdin.readline().split())
x2, y2 = map(int,sys.stdin.readline().split())
n = int(sys.stdin.readline())
lines = []
for i in range(n):
lines.append(map(int,sys.stdin.readline().split()))
res = 0
for a,b,c in lines:
v1 = x1*a + y1*b + c
v2 = x2*a + y2*b + c
if (v1 < 0 and v... | 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.*;
import java.io.*;
public class prb{
static int gcd(int a, int b){
return b == 0 ? a : gcd(b, a%b);
}
public static void main(String[] args){
Scanner in = new Scanner(System.in);
long x1 = in.nextLong();
long y1 = in.nextLong();
long x2 = in.nextLong();
... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | def isX(a,b,c):
det = a*bb-aa*b
if det == 0: return False
x = (b*cc-bb*c)*1.0/det
y = -(a*cc-aa*c)*1.0/det
if min(x1,x2) <= x <= max(x1,x2) and min(y1,y2) <= y <= max(y1,y2):
return True
else:
False
x1,y1 = map(int,raw_input().split())
x2,y2 = 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
int count = 0;
for (int i = 0; i < n; i++) {
long long int a, b, c;
cin >> a >> b >> c;
long long int pe1 = x1 * a + y1 * b;
long long int pe2 = x2 * a + y2 ... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class A {
BufferedReader reader;
StringTokenizer tokenizer;
PrintWriter out;
public void solve() throws IOException {
long X1 = 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() {
int x1, y1;
int x2, y2;
int n, a, b, c, sol = 0;
cin >> x1 >> y1 >> x2 >> y2 >> n;
for (int i = 0; i < n; i++) {
cin >> a >> b >> c;
long long t1 = 1LL * a * x1 + 1LL * b * y1 + c;
long long t2 = 1LL * a * x2 + 1LL * b * y2 + c;
if ((t... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | R=lambda:map(int,raw_input().split())
x,y=R()
u,v=R()
t=0
for _ in range(R()[0]):
a,b,c=R()
t+=(a*x+b*y+c>0)!=(a*u+b*v+c>0)
print t
| 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;
bool chomeeck(long long a, long long b, long long c, long long x1, long long x2,
long long y1, long long y2) {
long long p1 = a * x1 + b * y1;
long long p2 = a * x2 + b * y2;
return (p1 > (-c)) ^ (p2 > (-c));
}
int main() {
long long homex, homey, ux, ... | 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.geom.Line2D;
import java.util.*;
public class CrazyTown {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Point ME = new Point(scan.nextInt(), scan.nextInt());
Point U = new Point(scan.nextInt(), scan.nextInt());
Line2D.Double path = new Line2D.Double(ME.x, ME.... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
struct line {
double a, b, c;
line() {}
line(double a, double b, double c) {
this->a = a;
this->b = b;
this->c = c;
}
};
double Hx, Hy, Ox, Oy;
pair<bool, pair<double, double> > intersect(line l1, line l2) {
double det = l1.a * l2.b - l2.a * l1.b;
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;
const int INF = 1e9 + 100;
const int maxn = 2000000;
long long xx1, yy1, xx2, yy2, a, b, c, c1, c2;
int n, ans = 0;
int main() {
cin >> xx1 >> yy1 >> xx2 >> yy2;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a >> b >> c;
c1 = a * xx1 + b * yy1 + c;
c2 = 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 | x1,y1 = map(int, raw_input().split())
x2,y2 = map(int, raw_input().split())
n = int(raw_input())
total = 0
for _ in xrange(n):
a,b,c = map(int, raw_input().split())
if (a*x1+b*y1+c)*(a*x2+b*y2+c) < 0:
total += 1
print total | PYTHON |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
;
const double pi = acos(-1.0);
template <class T>
inline T sqr(T a) {
return a * a;
}
template <class T>
inline void read(T &n) {
char c;
for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
;
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 | get = lambda: map(int, raw_input().split())
x1, y1 = get()
x2, y2 = get()
n, = get()
lines = [get() for i in range(n)]
count = 0
for a,b,c in lines:
f1 = a * x1 + b * y1 + c
f2 = a * x2 + b * y2 + c
if (f1 < 0 and f2 > 0) or (f1 > 0 and f2 < 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 | h=list(map(int,input().strip().split()))
u=list(map(int,input().strip().split()))
n=int(input())
count=0
for i in range(n):
a,b,c=list(map(int,input().strip().split()))
t1=a*h[0]+b*h[1]+c
t2=a*u[0]+b*u[1]+c
#print(">",t1,t2)
if ((t1>0) != (t2>0)):
count+=1
print(count)
| PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.awt.geom.Line2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class CF284C {
private FastScanner in;
private PrintWriter out;
public void solve() throws IOException {
long x1 = in.next... | 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 getP(int x, int y, long long a, long long b, long long c) {
return a * x + b * y + c > 0;
}
void solve() {
int x0, y0, X1, Y1;
scanf("%d%d%d%d", &x0, &y0, &X1, &Y1);
int n;
scanf("%d", &n);
int ans(0);
for (int i(0), _l((int)(n)-1); i <= _l; ++i) {
in... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long sgn(long long a) { return a < 0 ? -1 : 1; }
int main() {
int x1, y1, x2, y2, n;
scanf("%d %d", &x1, &y1);
scanf("%d %d", &x2, &y2);
scanf("%d", &n);
int ans = 0;
for (int i = 0; i < n; i++) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
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 n, ans;
double xa, xb, ya, yb, a, b, c;
int main() {
scanf("%lf%lf%lf%lf%d", &xa, &ya, &xb, &yb, &n);
for (int i = 1; i <= n; i++) {
scanf("%lf%lf%lf", &a, &b, &c);
if (!b) {
if (c * -1 / a >= min(xa, xb) && c * -1 / a <= max(xa, xb)) ans++;
} else... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;
public class Main {
static class Point {
double ... | 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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Solution implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokeniz... | 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(void) {
long long n, x[2], y[2];
cin >> x[0] >> y[0] >> x[1] >> y[1];
cin >> n;
int answer = 0;
for (int i = (0); i < (n); ++i) {
long long a, b, c;
cin >> a >> b >> c;
if (a * x[0] + b * y[0] + c < 0 && a * x[1] + b * y[1] + c > 0) answer++;
... | 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())
univ = map(int, raw_input().split())
line = None
if home[0] == univ[0]:
line = [1,0,-home[0]]
elif home[1] == univ[1]:
line = [0,1,-home[1]]
else:
slope = (univ[1]-home[1])/(univ[0]-home[0])
line = [slope, -1, univ[1]-slope*univ[0]]
n = int(raw_input())
road = None
c... | PYTHON |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1.0);
const long double eps = 1e-10;
const double inf = 10e30;
double R_to_Angle(double rad) { return 180 / Pi * rad; }
double Angle_to_R(double angle) { return Pi / 180 * angle; }
int sgn(long double x) {
if (fabs(x) < eps) return 0;
if (x < 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 | #include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
int n, i, ans;
long long x1, y, x2, y2, t1, t2, a, b, c;
int main() {
cin >> x1 >> y >> x2 >> y2 >> n;
for (i = 1; i <= n; i++) {
cin >> a >> b >> c;
t1 = a * x1 + b * y + c;
t2 = a * x2 + b * y2 + c;
if ((t1 < 0 && t2 > 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 | def s(xx1,yy1,xx2,yy2,x1,y1):
return (xx1-x1)*(yy2-y1)-(yy1-y1)*(xx2-x1)
x1, y1 = map(int,input().split())
x2, y2 = map(int,input().split())
n = int(input())
l = [0] * n
for i in range(n):
l[i] = tuple(map(int,input().split()))
res = 0
for i in range(n):
a,b,c = l[i]
xx1 = 0
xx2 = 1000
yy1, yy2 ... | 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 xa, ya, xb, yb;
long long a, b, c, sum = 0, n;
int main() {
cin >> xa >> ya >> xb >> yb;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a >> b >> c;
if (((a * xa + b * ya + c) < 0 && (a * xb + b * yb + c) > 0) ||
((a * xa + b * ya + 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 | #include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, x_1, x_2, y_1, y_2, x, y, z, m, n, a, b, c, ans;
int main() {
scanf("%I64d %I64d %I64d %I64d %I64d", &x_1, &y_1, &x_2, &y_2, &n);
for (i = 1; i <= n; i++) {
scanf("%I64d %I64d %I64d", &a, &b, &c);
x = a * x_1 + b * y_1 + c;
y = a * x_2 ... | 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 MOD = 1e9 + 7;
const double EPS = 1e-8;
const double PI = 2 * acos(0.0);
const int MAXN = 1e6 + 5;
int n;
int main() {
long long xa, ya, xb, yb, ans = 0, a[303], b[303], c[303];
cin >> xa >> ya;
cin >> xb >> yb;
cin >> n;
for (int i = 1; i <= n; i++) cin... | 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
x, y = map(int, input().split())
u, v = map(int, input().split())
n = int(input())
s = 0
for i in range(n):
a, b, c = map(int, input().split())
s += (a * x + b * y + c > 0) ^ (a * u + b * v + c > 0)
print(s)
| PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
solve();
}
private static void solve() {
int x1 = IO.readInt();
int y1 = IO.readInt();
int x2 = IO.readInt();
int y2 = IO.readInt();
int n = IO.readInt();
int count = 0;
long a,b,c;
while (n-- > 0) {
a =... | 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(input())
c=0
for _ in xrange(n):
a1,b1,c1=map(int,raw_input().split())
if((a1*x1+b1*y1+c1)*(a1*x2+b1*y2+c1)<0):
c+=1
print c | PYTHON |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.awt.geom.Line2D;
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double intx1 = input.nextInt();
double inty1 = input.nextInt();
double intx2 = input.nextInt();
double inty2 = input.nextIn... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.*;
import java.util.*;
//public final class code
class code
{
static void solve()throws IOException
{
long x1=nextLong();
long y1=nextLong();
long x2=nextLong();
long y2=nextLong();
int n=nextInt();
int count=0;
while(n-->0)
{
long a=nextLong();
long b=nextLong();
long c=nextLo... | 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;
public class T499C {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int i,n,res=0;
long A,B,C,x1,y1,x2,y2,res1,res2;
x1=in.nextLong();
y1=in.nextLong();
x2=in.nextLong();
y2=in.nextLong();
n=in.nextInt();
long[]a=new long[n],b=new long[n],c=new ... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long power(long x, long n) {
if (n == 0) return 1;
if (n == 1) return x;
long n2 = n / 2;
long long po = power(x, n2);
if (n % 2) return po * po * x;
return po * po;
}
long long gcd(long long a, long long b) {
if (b == 0) return a;
a %= b;
return gcd(... | 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 | h1, h2 = list(map(int,input().split()))
u1, u2 = list(map(int,input().split()))
steps = 0
for i in int(input())*'_':
a, b, c= list(map(int,input().split()))
if (a * h1 + b * h2 + c) * (a * u1 + b * u2 + c) < 0:
steps+=1
print(steps) | PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int n;
long long a, b, c;
long long x1, yy, x2, y2;
int main() {
while (~scanf("%I64d%I64d%I64d%I64d", &x1, &yy, &x2, &y2)) {
scanf("%d", &n);
int num = 0;
for (int i = 1; i <= n; i++) {
scanf("%I64d%I64d%I64d", &a, &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>
const double eps = 1e-8;
int dcmp(double x) {
if (fabs(x) < eps) return 0;
return x < 0 ? -1 : 1;
}
int n, X1, Y1, X2, Y2, xmin, xmax, ymin, ymax;
int a, b, c;
double K, B;
bool f;
int chk() {
if (f) {
if (b == 0) return 0;
double y = (-c - a * X1) * 1.0 / b;
if (dcmp(y - ymin... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.