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 | read_line = lambda: [int(i) for i in input().split()]
x0, y0 = read_line()
x1, y1 = read_line()
print(sum((a * x0 + b * y0 + c) * (a * x1 + b * y1 + c) < 0 for a, b, c in (read_line() for i in range(int(input())))))
# Made By Mostafa_Khaled | 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.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual so... | 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);
long long x1, y1;
cin >> x1 >> y1;
long long x2, y2;
cin >> x2 >> y2;
long long n;
cin >> n;
long long ans = 0;
for (long long i = 0; i < n; i++) {
long long a, b, c;
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;
long long x, y, z, w, a, b, c, n, ans;
int main() {
cin >> x >> y >> z >> w >> n;
while (n--) {
cin >> a >> b >> c;
if (a * x + b * y + c > 0 != a * z + b * w + c > 0) ans++;
}
cout << ans;
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;
int main() {
long long ans = 0;
long long homex, homey;
long long schoolx, schooly;
cin >> homex >> homey;
cin >> schoolx >> schooly;
long long n;
cin >> n;
for (int i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
long long num1 = (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.*;
import java.util.*;
/**
* Created by Dimon on 14.12.2014.
*/
public class Solution {
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
double x1 = scanner.nextDouble();
double y1 = scanner.nextDouble();
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 | #input
x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
n=int(input())
r=[]
for i in range(n):
r.append([int(x) for x in input().split()])
#variables
def f(a,b,c,x,y):
if b*y>-c-a*x:
return 'UP'
else:
return 'DOWN'
s=n
#main
for i in range(n):
if f(r[i][0],r[i][1],r[i][2],x1,y1)==f(r[i][0],r[i][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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CrazyTown {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
Point home = new Point(sc.nextInt(),... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n, m, x1, y11, x2, y2, aa, bb, cc;
double ans1, ans2, a, b, c;
int ans = 0;
int main() {
scanf("%d%d%d%d", &x1, &y11, &x2, &y2);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%d%d", &aa, &bb, &cc);
c = -cc;
a = aa;
b = bb;
if (b != 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 |
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
n = int(input())
lines = [ tuple(map(int,input().split()) ) for _ in range(n) ]
def cal(a,b,c,p,q):
ux = -b
uy = a
if b==0:
y=0
x=-c/a
else:
x=0
y=-c/b
px,py = p
qx,qy = q
s1 = (px-x)*uy-(py-y)*ux
s2 = (qx-x)*uy-(qy-y)*ux
retur... | PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int A[2][2], n, a, b, c, d, e, i, ans = 0;
cin >> A[0][0] >> A[0][1] >> A[1][0] >> A[1][1];
cin >> n;
for (i = 0; i < n; i++) {
cin >> a >> b >> c;
d = (a * A[0][0] + b * A[0][1] + c);
e = (a * A[1][0] + b * A[1][1] + 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;
int a[2], b[2];
bool isOppo(vector<int> line) {
long long first = (long long)a[0] * line[0] + (long long)a[1] * line[1] +
(long long)line[2];
long long second = (long long)b[0] * line[0] + (long long)b[1] * line[1] +
(long... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
long long n;
cin >> n;
bool home[500];
bool uni[500];
long long A[500], B[500], C[500];
for (int i = 0; i < n; i++) {
cin >> A[i] >> B[i] >> C[i];
}
for (int i = 0; i < n; i++) {
... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.util.Arrays;
import java.util.Hashtable;
import java.util.Scanner;
public class Solution{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long x1 = sc.nextLong();
long y1 = sc.nextLong();
long x2 = sc.nextLong();
long y2 = sc.nextLong();
long n = sc.nextLong();
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 codeforces;
import java.io.*;
import java.util.*;
public class A {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer = new PrintWriter(System.out);
A() throws IOException {
// reader = new BufferedReader(new FileReader("input.txt"));
// ... | 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>
int main() {
long long int a, b, c, d;
scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
int e;
scanf("%d", &e);
int count = 0;
for (int i = 1; i <= e; i++) {
long long int f, g, h;
scanf("%lld%lld%lld", &f, &g, &h);
long long int s1 = f * a + g * b + h;
long long int s2 = ... | 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 pwr(long long base, long long p) {
long long ans = 1;
while (p) {
if (p & 1) ans = (ans * base) % (10000007LL);
base = (base * base) % (10000007LL);
p >>= 1;
}
return ans;
}
long long modInv(long long n, long long mod) { return pwr(n, mod - 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;
template <class T>
inline T poww(T b, T p) {
long long a = 1;
while (p) {
if (p & 1) {
a = (a * b);
}
p >>= 1;
b = (b * b);
}
return a;
}
template <class T>
inline T poww2(T b, int p) {
T a = 1;
while (p) {
if (p & 1) {
a = (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;
const long long inf = 1000000000ll;
const long long inf64 = inf * inf;
const long long base = inf / 10ll;
bool solve() {
long long x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
vector<pair<long long, pair<long long, long long> > > p(n);
for (int ... | 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 | __author__ = 'Rakshak.R.Hegde'
"""
Created on Dec 24 2014 PM 10:42
@author: Rakshak.R.Hegde
"""
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
n = int(input())
cost = 0
for i in range(n):
a, b, c = map(int, input().split())
d1 = a * x1 + b * y1 + c
d2 = a * x2 + b * y2 + c
if d1... | 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 = map(int, input().split())
xU, yU = map(int, input().split())
n = int(input())
def cross_product(a, b, c):
v1 = a * xH + b * yH + c
v2 = a * xU + b * yU + c
return v1 < 0 and v2 > 0 or v1 > 0 and v2 < 0
res = 0
for _ in range(n):
a, b, c = map(int, input().split())
if cross_product(a, b ,c... | 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.*;
public class C {
void solve() throws IOException {
double x1 = nextDouble(), y1 = nextDouble();
double x2 = nextDouble(), y2 = nextDouble();
long counter = 0;
for (int t = nextInt(); t > 0; --t) {
double a = nextDouble(), b = nextDo... | 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 = map(int, input().split())
ux, uy = map(int, input().split())
n = int(input())
count = 0
for i in range(n):
a,b,c = map(int, input().split())
h = a*hx + b*hy + c
u = a*ux + b*uy + c
if h*u<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.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStreamReader;
import java.io.IOException;
/**
* Built using CHelper plug-in
* Actual soluti... | 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 crazytown {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int hx = s.nextInt();
int hy = s.nextInt();
int ux = s.nextInt();
int uy = s.nextInt();
int co = s.nextInt();
int steps =0;
while(co-- >0){
long a = s.nextLong();
long b = s.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 | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.u... | 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(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()]
x = x1 * a + y1 * b + c
x //= abs(x)
y = x2 * a + y2 * b + c
y //= abs(y)
if x != y:
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;
const int maxn = 1e6 + 100;
const long long inf = 0x3f3f3f3f;
inline long long rd() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch ... | 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 x[2], y[2], dis[2];
long long a, b, c;
int n;
int main() {
int ans = 0;
for (int i = 0; i < 2; i++) {
scanf("%lld%lld", &x[i], &y[i]);
}
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lld%lld%lld", &a, &b, &c);
for (int j = 0; j < 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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static long xu, xh, yu, yh, a, b, c;
public static boolean intersect(){
return ((a*xu + b*yu + c > 0L) != (a*xh + b*yh + c) > 0L) ;
}
public sta... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int x1, x2, y1, y2;
scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
long long int n, a, b, c;
scanf("%lld", &n);
long long int ans = 0;
while (n--) {
scanf("%lld %lld %lld", &a, &b, &c);
if (((a * x1 + b * y1 + c) > 0 && (a * x2 ... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x1, x2, y1, y2;
long long a, b, c;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
int ans = 0;
while (n--) {
scanf("%lld%lld%lld", &a, &b, &c);
if (((a * x1 + b * y1 + c) / abs(a * x1 + b * y1 + c)) *
((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;
int toInt(string s) {
int r = 0;
istringstream sin(s);
sin >> r;
return r;
}
long long toInt64(string s) {
long long r = 0;
istringstream sin(s);
sin >> r;
return r;
}
double toDouble(string s) {
double r = 0;
istringstream sin(s);
sin >> r;
return r... | 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.*;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
public class A {
public A() throws Exception {
long x1 = in.nextInt();
long y1 = in.nextInt();
long x2 = in.nextInt();
long y2 = in.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 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
public class CF2 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(Syste... | 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 i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int x1, y1, x2, y2;
std::cin >> x1 >> y1 >> x2 >> y2;
int ans = 0;
int n;
std::cin >> n;
for (int i = 0; i < n; i++) {
int a, b, c;
std::cin >> a >> b >> c;
i64 A = i64(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.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.math.BigInteger;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
/**
* Built using CHelpe... | 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 double eps = 1e-6;
int dcmp(double x) {
if (fabs(x) < eps) return 0;
return (x < 0) ? -1 : 1;
}
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); }
Point... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
const int N = 310;
const double eps = 1e-12;
using namespace std;
int sgn(double x) {
if (fabs(x) < eps) return 0;
if (x > 0)
return 1;
else
return -1;
}
int ans = 0;
struct Point {
double x, y;
Point() {}
Point(double _x, double _y) { x = _x, y = _y; }
bool operator<(Poin... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Main implements Runnable {
private void solve(QuickScanner in, PrintWriter out) {
double x1 = in.nextInt(), y1 = in.nextInt(), x2 = in.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 | import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(Sys... | 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.*;
/**
*
* @author Saju
*
*/
public class Main {
private static int dx[] = { 1, 0, -1, 0 };
private static int dy[] = { 0, -1, 0, 1 };
private static final long INF = (long) Math.pow(10, 16);
private static final int INT_INF = Integer.MAX_VA... | 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 CrazyTown {
public static void main (String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(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;
int main() {
long long xh, yh, xu, yu, at, bt, ct, ans = 0, n;
cin >> xh >> yh >> xu >> yu >> n;
while (n--) {
cin >> at >> bt >> ct;
ans += (at * xh + bt * yh < -ct) ^ (at * xu + bt * yu < -ct);
}
cout << ans;
}
| 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.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
/*
br = new BufferedReader(new FileReader("input.txt"));
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
br = new Bu... | 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 line_a;
long long line_b;
long long line_c;
int nlines;
int cross = 0;
long long x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2 >> nlines;
for (int i = 0; i < nlines; i++) {
cin >> line_a >> line_b >> line_c;
if ((line_a * x1 + li... | 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 |
xh, yh = map(int, raw_input().split())
xu, yu = map(int, raw_input().split())
def order(a, b, c, x, y):
if a*x + b*y + c > 0:
return 1
else:
return 0
n = input()
lines = [map(int, raw_input().split()) for _ in range(n)]
order_h = map(lambda l: order(l[0], l[1], l[2], xh, yh), lines... | 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 | hx,hy = map(int, raw_input().strip().split())
ux, uy = map(int, raw_input().strip().split())
ans = 0
n = input()
for i in range(n):
a,b,c = map(int, raw_input().strip().split())
x = a*hx + b*hy + c
y = a*ux + b*uy + c
if abs(x) + abs(y) != abs(x+y):
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;
int main() {
long long x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
int cnt = 0;
while (n--) {
long long int a, b, c;
cin >> a >> b >> c;
long long int s1 = ((a * x1 + b * y1 + c) > 0);
long long int s2 = ((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 | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//package javaapplication33;
import java.awt.Point;
import java.io.IOException;
import java.util.Scanner;
/**
*
* @author HIMANSHU
... | 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 | a , b = map(int, input("").split(" "))
c , d = map(int, input("").split(" "))
dumb = int(input(""))
lines = []
for value in range(dumb):
lines.append(input("").split(" "))
count = 0
check1 = 0
check2 = 0
for value in lines:
if (int(value[0])*a + int(value[1])*b+int(value[2])>= 0):
check1 = 1
else:
... | 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 int a, b, c, d;
long long int sgn(long long int k) {
if (k > 0) return 1;
if (k < 0) return -1;
return 0;
}
void sol() {
scanf("%I64d %I64d", &a, &b);
scanf("%I64d %I64d", &c, &d);
int n;
scanf("%d", &n);
int ans = 0;
for (int i = 0; i < n; i++) ... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | x, y = map(int, raw_input().split())
X, Y = map(int, raw_input().split())
ans = 0
n = int(raw_input())
for _ in xrange(n):
a, b, c = map(int, raw_input().split())
if (a * x + b * y + c) * (a * X + b * Y + 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.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CrazyTown {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
Poin... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.math.BigInteger;
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
* @author... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (b == 0 && a == 0) return 1;
if (b == 0) return a;
if (a == 0) return b;
return gcd(b, a % b);
}
void reduce(long long &a, long long &b) {
long long g = gcd(a, b);
if (g == 0) return;
a /= g;
b /= g;
}
bool isless... | 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 = 0x7fffffff;
const int MINF = 0x80000000;
const long long mod = 1000000007;
const int cons = 100001;
long long fn(long long a, long long b, long long c, long long x, long long y) {
return a * x + b * y + c;
}
int main() {
long long x[2], y[2];
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x1, x2, y1, y2;
scanf("%lld%lld", &x1, &y1);
scanf("%lld%lld", &x2, &y2);
int t;
int ans = 0;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
long long a, b, c;
scanf("%lld%lld%lld", &a, &b, &c);
if ((a * x1 + b * y1 + 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 | /**
* ******* Created on 30/12/19 5:23 AM*******
*/
import java.io.*;
import java.util.*;
public class A498 implements Runnable {
private static final int MAX = (int) (1E5 + 5);
private static final int MOD = (int) (1E9 + 7);
private static final long Inf = (long) (1E14 + 10);
private void solve(... | 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 A {
BufferedReader br;
PrintWriter out;
StringTokenizer st;
boolean eof;
void solve() throws IOException {
long x1 = nextLong();
long y1 = nextLong();
long x2 = nextLong();
long y2 = nextLong();
int n = nextInt();
int ret = 0;
for (int i = 0; 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 | /**
* Created by watson on 24.12.14.
*/
import java.util.*;
import java.io.*;
public class A {
FastScanner in;
PrintWriter out;
public void solve() throws IOException {
long x1 = in.nextInt();
long y1 = in.nextInt();
long x2 = in.nextInt();
long y2 = in.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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CrazyTown {
public static void main(String[]args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringT... | 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(NULL);
cout.tie(NULL);
long long x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
int ans = 0;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
long long f = 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.awt.*;
import java.awt.geom.Area;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Map.Entry;
import javax.management.RuntimeErrorException;
import static java.lang.Math.*;
public class Solution implements Runnable {
final boolean ONLINE_JUDGE = System.getProperty(... | 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 sign(long long x) { return x < 0 ? -1 : 1; }
int main() {
ios::sync_with_stdio(0);
long long x1, y1, x2, y2, n;
cin >> x1 >> y1 >> x2 >> y2 >> n;
int res = 0;
for (int i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
if (sign(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 | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
int r = 0;
for (int i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
long long p = a * x1 + b * y1 + c;
long long q = a * x2 + b * y2 + c;
if (p > 0 && ... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class ProbC {
public static void main(String args[]) {
InputStream inputStream = Syste... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | x, y = map(int, input().split())
u, v = map(int, input().split())
s = 0
for i in range(int(input())):
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 | #include <bits/stdc++.h>
using namespace std;
void doin() {
cin.tie();
cout.tie();
ios::sync_with_stdio(0);
}
float X, Y, X1, Y1, a, b, c, xt, xx;
int ans = 0, n;
int main() {
doin();
cin >> X >> Y >> X1 >> Y1;
cin >> n;
while (n--) {
cin >> a >> b >> c;
ans += ((a * X + b * Y + c < 0) ^ (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 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CrazyTown {
static final double EPS = 1e-9;
static final double oo = 1e9;
static class Point implements Comparable<Point> {
// Global Variabl... | 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, ans = 0, r1, r2;
cin >> x1 >> y1 >> x2 >> y2;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a >> b >> c;
r1 = (a * x1) + (b * y1) + c;
r2 = (a * x2) + (b * y2) + c;
if ((r1 > 0 and r2 < 0) or (r1 < ... | 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;
import java.util.*;
public class contest1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
int mx=s.nextInt();
int my=s.nextInt();
int rx=s.nextInt();
int ry=s.nextInt();
int lines=s.nextInt();
long[][] p=new l... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #!/usr/bin/env python3
import collections, itertools, functools, math
def value(a, b, c, x, y):
return a*x + b*y + c
def sign(x):
if x < 0:
return -1
if x == 0:
return 0
if x > 0:
return 1
def solve():
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split(... | 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;
vector<bool> sieve(long long n) {
vector<bool> prime(n + 1, true);
prime[0] = prime[1] = false;
for (long long i = 2; i <= n; ++i) {
if (prime[i] && (i * i) <= n)
for (long long j = i * i; j <= n; j += i) prime[j] = false;
}
return prime;
}
long long pow... | 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.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 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double gammama = 0.57721566490153286060;
const long double eps = 1e-5;
const int INF = 1000 * 1000 * 1000 + 1;
const long long LINF = (long long)1000 * 1000 * 1000 * 1000 *... | 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>
template <class T>
inline T gcd(T x, T y) {
if (!y) return x;
return gcd(y, x % y);
}
template <class T>
inline void read(T& x) {
bool fu = 0;
char c;
for (c = getchar(); c <= 32; c = getchar())
;
if (c == '-') fu = 1, c = getchar();
for (x = 0; c > 32; c = getchar()) x = x * ... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Codeforces499C
{
public static double crossProduct(double x1, double y1, double a, double b, double c)
{
return a*x1 + b*y1 + c;
}
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>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
template <class T>
inline bool read(T &n) {
T x = 0, tmp = 1;
char c = getchar();
while ((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();
if (c == EOF) return false;
if (c == '-') c = getchar(), 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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CF_498_A_CRAZY_TOWN {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
Point home = new Point(sc.n... | JAVA |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
const int ms = 1e5 + 20;
int a[ms];
int main() {
long long x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
int n;
cin >> n;
int ans = 0;
for (int i = 0; i < n; i++) {
long long a, b, c;
scanf("%lld %lld %lld", &a, &b, &c);
long long me = 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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x1, y1, x2, y2;
scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
int n, ans(0);
long long a, b, c;
scanf("%d", &n);
while (n--) {
scanf("%lld %lld %lld", &a, &b, &c);
if ((a * x1 + b * y1 + c > 0 && a * x2 + b * y2 + c < 0) ||
... | CPP |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | def get():
return map(int,raw_input().split())
A = get()
B = get()
n = int(raw_input())
lines = [get() for _ in xrange(n)]
def subs(l1,p):
return l1[0] * p[0] + l1[1]*p[1] + l1[2]
def check(l1):
a = subs(l1,A)
b = subs(l1,B)
return (a>0 and b < 0) or (a < 0 and b>0)
print len(filter(check,lines... | 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.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class CF_284C {
static Reader sc = new Reader();
public static void main(String[] args) throws IOException {
Point a = new Point(sc.nextDouble(), sc.nextDouble());
... | 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 n, a[1 << 21], s;
int main() {
long long int a, b, x, y, m, t, o, c = 0, h, u;
cin >> a >> b >> x >> y >> n;
while (n--) {
cin >> m >> t >> o;
h = (a * m + b * t + o > 0) ? 1 : -1;
u = (x * m + y * t + o > 0) ? 1 : -1;
if (h * u == -1) 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 | x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
ans = 0
n = input()
for i in range(n):
a, b, c = map(int, raw_input().split())
d1 = a * x1 + b * y1 + c
d2 = a * x2 + b * y2 + c
if d1 * d2 < 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.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class A498 implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
public static void main(String[] args) {
new Thread(null, new A498... | 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.text.*;
import java.math.*;
import java.util.regex.*;
public class sou {
public static void main(String[]args) {
Scanner sc=new Scanner(System.in);
int x1=sc.nextInt();
int y1=sc.nextInt();
int x2=sc.nextInt();
int y2=sc.nextInt();
int n=sc.nextInt();
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 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long x1, x2, y1, y2, a, b, c, n, r;
scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
scanf("%lld", &n);
for (r = 0; n--;) {
scanf("%lld%lld%lld", &a, &b, &c);
long long t = a * x1 + b * y1 + c;
long long v = a * x2 + 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 | #include <bits/stdc++.h>
using namespace std;
struct node {
long long int a, b, c;
} node1[305];
int main(void) {
long long int x1, y1, x2, y2, n, a, b, c;
while (scanf("%lld%lld", &x1, &y1) != EOF) {
scanf("%lld%lld", &x2, &y2);
scanf("%lld", &n);
int i, ans = 0;
for (i = 0; i < n; i++) {
s... | 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 x, y;
scanf("%d", &x);
scanf("%d", &y);
int x2, y2;
scanf("%d", &x2);
scanf("%d", &y2);
int n, a, b, c;
scanf("%d", &n);
long long sign1, sign2;
int ans = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &a);
scanf("%d", &b);
s... | 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.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
public class algorithms{
public static void main(String... | 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 x, y, z, a1, b1, a2, b2;
scanf("%lf%lf%lf%lf", &a1, &b1, &a2, &b2);
int n, c = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%lf%lf%lf", &x, &y, &z);
if ((a1 * x + b1 * y + z) * (a2 * x + b2 * y + z) < 0) {
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 | x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
n = int(input())
ans = 0
for i in range(n):
a, b, c = map(int, input().split())
f1 = a * x1 + b * y1 + c
f2 = a * x2 + b * y2 + c
if f1 * f2 < 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;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
if (a.first == b.first)
return a.second < b.second;
else
return a.first < b.first;
}
long long exp(long long a, long long b) {
long long ans = 1;
while (b != 0) {
if (b % 2) ans = ans... | 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())
n = int(input())
s = 0
for i in range(n):
a,b,c = map(int,input().split())
if ((((a * x1) + (b * y1) + c) * ((a * x2) + (b * y2) + c)) < 0):
s = s + 1
print(s) | PYTHON3 |
498_A. Crazy Town | Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int x, y, xx, yy;
int ans, n;
int main() {
scanf("%d %d", &x, &y);
scanf("%d %d", &xx, &yy);
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (1.0 * a * x + 1.0 * b * y + c > 0.0 &&
1.0 * a * xx + 1.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;
vector<bool> prime;
vector<long long> fact, inv, primes, factors;
void factorize(long long a) {
fact.clear();
for (long long i = 1; i * i <= a; i++) {
if (i * i == a)
factors.push_back(i);
else if (a % i == 0) {
factors.push_back(i);
factors.pu... | 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 = 250, MAXBS = 1000000;
const double PI = acos(-1);
struct dot {
long long x, y;
dot(long long x = 0, long long y = 0) : x(x), y(y) {}
};
struct line {
long long a, b, c;
bool side(dot p) { return (a * p.x + b * p.y > -c); }
};
int n, total;
dot 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() {
ios::sync_with_stdio(0);
cin.tie(0);
long long x1, y1, x2, y2;
cin >> x1 >> y1;
cin >> x2 >> y2;
long long n;
cin >> n;
long long ans = 0;
for (int i = 0; i < n; i++) {
long a, b, c;
cin >> a >> b >> c;
if ((a * x1 + b * y1 + c) > ... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.