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
import java.io.InputStream; import java.io.PrintStream; import java.util.Scanner; public final class Solution { public static void main(String[] args) { parseSolveAndPrint(System.in, System.out); } public static void parseSolveAndPrint(InputStream in, PrintStream out) { Scanner scanner ...
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 a, b, c; long long get(long long x, long long y) { return a * x + b * y + c; } int main() { int x1, x2, y1, y2, n; scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &n); int ans = 0; for (int i = 0; i < n; i++) { scanf("%d%d%d", &a, &b, &c); if ((get(x1, y1) ^ get...
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 = list(map(int,input().split())) x2, y2 = list(map(int,input().split())) steps = 0 for i in int(input())*'_': a, b, c= list(map(int,input().split())) if (a * x1 + b * y1 + c) * (a * x2 + b * y2 + 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; int main() { long long hx, hy, ux, uy; cin >> hx >> hy >> ux >> uy; int n; cin >> n; long ans = 0; for (int i = 0; i < n; i++) { long long a, b, c; cin >> a >> b >> c; long long s1 = a * hx + b * hy + c; long long s2 = a * ux + b * uy + 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 main() { long long x, y, x1, y1; cin >> x >> y >> x1 >> y1; int n, cnt = 0; cin >> n; while (n--) { long long a, b, c; cin >> a >> b >> c; cnt += (a * x + b * y + c > 0) ^ (a * x1 + b * y1 + c > 0); } cout << cnt << endl; 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() { double nowx; long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int n; long long a, b, c, u1, u2, ans = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; u1 = a * x1 + b * y1 + c; u2 = a * x2 + b * y2 + c; if ((u1 ...
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> #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; int main() { int T, i, j, k, ca = 0, n, m; int x1, y1, x2, y2; while (~scanf("%d%d%d%d", &x1, &y1, &x2, &y2)) { scanf("%d", &n); int ans = 0, a, b, c; while (n--) { scanf("%d%d%d", &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
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner (System.in); int xa, ya, xb, yb; int n, ans=0, a, b, c; xa=s.nextInt(); ya=s.nextInt(); xb=s.nextInt(); yb=s.nextInt(); n=s.nextInt(); for (int i = 1; i <= n; ++i) {a=s.nextInt(); b=s.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> inline int Input() { int ret = 0; bool isN = 0; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') isN = 1; c = getchar(); } while (c >= '0' && c <= '9') { ret = ret * 10 + c - '0'; c = getchar(); } return isN ? -ret : ret; } inline void Output(long l...
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 main(): x1, y1 = map(float, input().split()) x2, y2 = map(float, input().split()) n = int(input()) res = 0 for _ in range(n): a, b, c = map(float, input().split()) if a and b: x3, y3, x4, y4 = 0., -c / b, 1., -a / b elif a: x3, y4 = -c / a, 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
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); double x1, y1; double x2, y2; int n, ans = 0; cin >> x1 >> y1; cin >> x2 >> y2; double a1 = y1 - y2, b1 = x2 - x1, c1 = (a1 * x1 + b1 * y1) * (-1); cin >> n; for (long long int(i) = 0; (i) < (long long 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
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) n = int(input()) steps = 0 for i in range(n): a, b, c = map(int, input().split()) if (((a*x1 + b*y1 + c) < 0) != ((a*x2 + b*y2 + 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
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x1 = in.nextInt(),y1 = in.nextInt(); int x2 = in.nextInt(),y2 = in.nextInt(); int n = in.nextInt(); int ans = 0; for(int i=0;i<n;i++){ double a,b,c; a = in.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; int a[300], b[300], c[300]; int main() { long long x, y, v, w, n; cin >> x >> y >> v >> w >> n; for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i]; int count = 0; for (int i = 0; i < n; i++) if (a[i] * x + b[i] * y + c[i] > 0 && a[i] * v + b[i] * w + c[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; void in() {} int main() { in(); long long x1, y1, x2, y2, cnt = 0; ; cin >> x1 >> y1 >> x2 >> y2; long long n, a, b, c, p1, p2; cin >> n; while (n--) { cin >> a >> b >> c; p1 = a * x1 + b * y1 + c; p2 = a * x2 + b * y2 + c; if ((p1 < 0 && p2 > ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double PI = acos(-1.); const long long MOD = 1000000007; int sign(long long x) { return x < 0 ? -1 : x > 0; } int main() { int i, j, k, _T; long long x1, y1, x2, y2; while (cin >> x1 >> y1 >> x2 >> y2) { int n; scanf("%d", &n); ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import sys def pyes_no(condition) : if condition : print "YES" else : print "NO" def plist(a, s = ' ') : print s.join(map(str, a)) def rint() : return int(sys.stdin.readline()) def rints() : return map(int, sys.stdin.readline().split()) def rfield(n, m = None) : if m == None : m = n fi...
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; struct Point { long long int x, y; Point() { x = 0, y = 0; } Point(int a, int b) { x = a, y = b; } }; int main() { Point A, B; cin >> A.x >> A.y >> B.x >> B.y; int i, n; long long left, right, a, b, c; int ans = 0; cin >> n; for (i = 0; i < n; ++i) { ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
''' β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β–“β–ˆβ–ˆβ–ˆβ–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β–“β•¬β•¬β–“β–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–“β–“β–“β–“β•¬β•¬β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•¬β•¬β•¬β•¬β•¬β•¬β–ˆβ–ˆβ–ˆβ–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β–ˆ β–ˆβ–ˆβ–ˆβ–“β–“β–“β–“β•¬β•¬β•¬β•¬β•¬β•¬β–“β–ˆβ–ˆβ•¬β•¬β•¬β•¬β•¬β•¬β–“β–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β–“β–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–“β–“β–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β–“β–ˆβ–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β–“β–ˆ β–ˆβ–ˆβ–ˆβ–“β–ˆβ–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–“β–ˆβ–ˆβ–ˆβ–“β•¬β•¬β•¬β•¬β•¬β•¬β–“β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β•¬β•¬β•¬β•¬β–“β–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–“β–ˆβ–“β•¬β•¬β•¬β•¬β•¬β–“β–“β–“β–“β–“β–“β–“β–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β–ˆ β–ˆβ–ˆβ–ˆβ–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–ˆβ–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β–“β–ˆ β–ˆβ–ˆβ–ˆβ–ˆβ–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–ˆβ–“β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬β•¬...
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> struct point { long long int x; long long int y; }; template <typename T> int sgn(T val) { return (T(0) < val) - (val < T(0)); } int main() { point A, B; long long int n, a, b, c; unsigned long int steps = 0; std::cin >> A.x; std::cin >> A.y; std::cin >> B.x; std::cin >> B.y...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
home = map(int, raw_input().split()) university = map(int, raw_input().split()) n = input() lines = [] ans = 0 for road in xrange(n): ai, bi, ci = map(int, raw_input().split()) p = ai*home[0] + bi*home[1] + ci q = ai*university[0] + bi*university[1] + ci if (p < 0 and q > 0) or (p > 0 and q < 0): ans += 1 p...
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.Scanner; public class Town { private static boolean intersect(int[] p1, int[] p2, long[] line) { return Math.signum(line[0] * p1[0] + line[1] * p1[1] + line[2]) != Math.signum(line[0] * p2[0] + line[1] * p2[1] + line[2]); } public static void main(String[] args) { Scanner in = 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 n, ans, hx, hy, ux, uy, data[300][3]; bool test(long long a, long long b, long long c) { return (a * hx + b * hy + c > 0) ^ (a * ux + b * uy + c > 0); } int main() { cin >> hx >> hy >> ux >> uy >> n; for (int i = 0; i < n; i++) { long long a, b, c; c...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long hx, hy, ux, uy, a, b, c; cin >> hx >> hy >> ux >> uy; long long n, cnt = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> a >> b >> c; if ((a * hx + b * hy + c) < 0 && (a * ux + b * uy + c) > 0) cnt++; else if ((a * hx + b...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x1,y1=map(int,raw_input().split()) x2,y2=map(int,raw_input().split()) n=int(raw_input()) rs=0 for i in xrange(n): a,b,c=map(int,raw_input().split()) if ((a*x1+b*y1+c)*(a*x2+b*y2+c))<0: rs+=1 print rs
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; double ax, ay, bx, by; bool check(double x, double y) { int ok = 0; if (x <= max(ax, bx) && x >= min(ax, bx)) ok++; if (y <= max(ay, by) && y >= min(ay, by)) ok++; return ok == 2 ? true : false; } double a, b, c, p, q; void cal(double &cx, double &cy) { if (fabs(b...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
x1,y1 = map(int,input().split()) x2,y2 = map(int,input().split()) n = int(input()) num = 0 for i in range(n): a,b,c = map(int,input().split()) num += (a * x1 + b * y1 + c > 0) != (a * x2 + b * y2 + c > 0) print(num)
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 Solution { StringTokenizer st; BufferedReader in; PrintWriter out; void solve() throws IOException { //in = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"), "ISO-8859-1")); ///out = new PrintWriter(new OutputS...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.*; public class CrazyTown499C { public static void main(String[] args) { // Set up scanner Scanner sc = new Scanner(System.in); // System.out.println("Enter x of home"); long xh = sc.nextLong(); // System.out.println("Enter y of home"); long ...
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.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Scanner; public class Main { static FasterScanner sc; //static ArrayList<Integer>[] arr; //static boolean[] b; public ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; double x1, y_1, x2, y2; int n; int main() { cin >> x1 >> y_1 >> x2 >> y2; cin >> n; double a, b, c; int res = 0; for (int i = 0; i < n; i++) { cin >> a >> b >> c; if (a == 0) { res += ((y_1 > -c / b) + (y2 > -c / b) == 1); } else 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class P5_CrazyTown { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); StringTokenize...
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 CF; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class D { public static void main(String[] args) throws IOException { Scanner bf = new Scanner(Syst...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long int x1, y1, x2, y2, a, b, c, p1, p2; cin >> x1 >> y1 >> x2 >> y2; long long int n; cin >> n; long long int ans = 0; for (int i = 0; i < n; i++) { cin >> a >> b >> c; p1 = a * x1 + b * y1 + c; p2 = a * x2 + b * y2 + 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 <cstdlib> #include <cstdarg> #include <cassert> #include <cctype> // tolower #include <ctime> #include <cmath> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <stdexcept> #include <map> #include <tuple> #include <unordered_map> #include <set> #include <list> #include <st...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:256000000") using namespace std; const double infd = 2e+9; const int infi = (1 << 30) - 1; const long long infl = (1ll << 60) - 1; const int mod = 1e+9 + 7; template <class T> inline T sqr(T x) { return x * x; } struct pt { int x, y; static pt get() { p...
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 problem499C { public static void main (String[]args) throws IOException{ BufferedReader x=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(x.readLine()); long x1=Long.parseLong(st.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; int main() { long long n, X1, Y1, X2, Y2, a, b, c; while (cin >> X1 >> Y1) { cin >> X2 >> Y2; cin >> n; vector<int> V1, V2; for (int i = 0; i < n; i++) { cin >> a >> b >> c; if (a * X1 + b * Y1 + c > 0) V1.push_back(1); 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
h1, h2 = list(map(int,input().split())) u1, u2 = list(map(int,input().split())) pasos = 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: pasos+=1 print(pasos)
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
from __future__ import division home = map(int, raw_input().split()) univ = map(int, raw_input().split()) n = input() roads = [map(int, raw_input().split()) for _ in xrange(n)] def isacross(a, b, c): home_val = a * home[0] + b * home[1] + c univ_val = a * univ[0] + b * univ[1] + c return ((home_val < 0 an...
PYTHON
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.Scanner; import java.util.TreeMap; public class ProblemE { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); double xh = scanner.nextDouble(), yh = scanner.nextDouble(), xu = scanner.nextDouble(), yu...
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 bet(double val, double a, double b) { return (val >= a && val <= b) || (val >= b && val <= a); } struct line { double a, b, c; long long x1, x2, y1, y2; line(long long _x1, long long _y1, long long _x2, long long _y2) { x1 = _x1, y1 = _y1, x2 = _x2, y2 = _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
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) n = int(input()) num_sign_diff = 0 for road in range(n): a, b, c = map(int, input().split()) pos1 = (a * x1 + b * y1 + c) > 0 pos2 = (a * x2 + b * y2 + c) > 0 if pos1 + pos2 == 1: #exactly one of them is on positive side of line num_sign_diff +...
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; struct Point { long long x; long long y; }; struct Vector { long long x; long long y; Vector(long long a, long long b) { x = a; y = b; } Vector(Point A, Point B) { x = B.x - A.x; y = B.y - A.y; } }; int sign(long long a) { if (a > 0) 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.io.*; import java.util.StringTokenizer; public class Main { static MyScanner in; static PrintWriter out; //static Timer t = new Timer(); public static void main(String[] args) throws IOException { in = new MyScanner(); out = new PrintWriter(System.out, true); ...
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
/* PROB: Main LANG: JAVA */ import java.io.*; import java.util.*; import java.awt.geom.Line2D; public class Main{ final double LRG = 100001.0; void run() throws Exception { long x1 = nextLong(), y1 = nextLong(), x2 = nextLong(), y2 = nextLong(); int N = nextInt(); int cnt = 0; ...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e6 + 5; const long long MOD = 1e9 + 7; struct Line { double a, b, c; }; int main() { pair<double, double> home, univ; cin >> home.first >> home.second; cin >> univ.first >> univ.second; int n; cin >> n; vector<Line> v(n); int ans = 0; for...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
if __name__ == '__main__': xhome, yhome = [int(x) for x in input().split()] xuni, yuni = [int(x) for x in input().split()] n_roads = int(input()) n_steps = 0 for i in range(n_roads): a, b, c = [int(x) for x in input().split()] hline = (a*xhome) + (b*yhome) + c uline = (a*xuni...
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; map<string, string> cc; int n; int main() { long long x1, y1, x2, y2; while (scanf("%I64d%I64d", &x1, &y1) == 2) { scanf("%I64d%I64d", &x2, &y2); scanf("%d", &n); long long a, b, c, ans = 0; for (int i = 0; i < n; ++i) { scanf("%I64d%I64d%I64d", &a...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long x, y; long long a, b; cin >> x >> y; cin >> a >> b; long long n; cin >> n; long long ans = 0ll; long long k, l, m; for (long long i = 0ll; i < n; ++i) { cin >> k >> l >> m; ...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.io.InputStreamReader; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using...
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:1000000000") using namespace std; const bool db = false; int n; double a[100010], b[100010], c[100010]; double sx, sy, fx, fy; set<pair<double, double> > in; pair<double, double> intr(double A1, double B1, double C1, double A2, double B2, ...
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,input().split()) p,q = map(int,input().split()) n = int(input()) k = 0 for i in range(n): a,b,c = map(int,input().split()) if (((a*x)+(b*y)+(c))*((a*p)+(b*q)+c))<0 : k+=1 print(k)
PYTHON3
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int n; long long x2, x3, y2, y3; int main() { cin >> x3 >> y3 >> x2 >> y2; scanf("%d", &n); int ans = 0; for (int i = 1; i <= n; i++) { long long a, b, c; cin >> a >> b >> c; long long res1, res2; res1 = a * x2 + b * y2 + c; res2 = a * x3 + b * 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
import java.util.*; import java.io.*; public class cf { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); long x1 = sc.nextInt(), y1 = sc.nextInt(); long x2 = sc.nextInt(), y2 = sc.nextInt(); int k = 0; int n = sc.nextInt(); for (int i = 0; i < n; 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
import java.io.IOException; import java.util.Hashtable; import java.util.InputMismatchException; import java.util.Scanner; public class cf284_c { public static long A1,B1,A2,B2; public static void main(String args[]){ Scanner s=new Scanner(System.in); A1=s.nextLong(); B1=s.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; long long sx, sy, ex, ey; int n; int main() { cin >> sx >> sy; cin >> ex >> ey; cin >> n; int ans = 0; while (n--) { long long a, b, c; cin >> a >> b >> c; int f1 = (sx * a + sy * b + c) > 0 ? 1 : 0; int f2 = (ex * a + ey * b + c) > 0 ? 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; long long a, b, c, d; long long N, A, B, C; int ans = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> a >> b >> c >> d; cin >> N; for (int i = 0; i < N; i++) { cin >> A >> B >> C; long long x = a * A + b * B + C; long long y = 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; inline long long MIN(long long a, long long b) { return a > b ? b : a; } inline long long MAX(long long a, long long b) { return a > b ? a : b; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); long long arr[2][2]; for (long long i = 0; i < 2; 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
x1,y1=map(int,input().split()) x2,y2=map(int,input().split()) n=int(input()) summa=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: summa+=1 print(summa)
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.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.Optional; import javax.swing.text.html.Option; /** * @author grozhd */ public class Geometry { static Point home; static Point uni; static List<Line> lines; public s...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; const int N = 1e6 + 5; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } int max(int a, int b) { return a > b ? a : b; } template <typename T> T min(T a, T b) { return a < b ? a : b; } vector<vector<long long>...
CPP
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> using namespace std; int n; long long a, b, c, xs, ys, xe, ye; int cnt; int main() { cin >> xs >> ys; cin >> xe >> ye; scanf("%d", &n); while (n--) { cin >> a >> b >> c; if (!((a * xs + b * ys > -c && a * xe + b * ye > -c) || (a * xs + b * ys < -c && a * xe + b * ye < ...
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 #sys.stdin = open('input.txt', 'r') #sys.stdout = open('output.txt', 'w') def norm(a, b, c, d): if (b * c >= 0): return a * abs(c) <= abs(b) <= d * abs(c) return -a * abs(c) >= abs(b) >= -d * abs(c) x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) a2 = y2 - y1 b2 = x1 - x2 c2 = 0 ...
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> int sx, sy, ex, ey; int N, A[333], B[333], C[333]; long long D[333], E[333]; int main() { int i, j, k; scanf("%d%d%d%d%d", &sx, &sy, &ex, &ey, &N); for (i = 1; i <= N; i++) scanf("%d%d%d", A + i, B + i, C + i); for (i = 1; i <= N; i++) { D[i] = (long long)A[i] * sx + (long long)B[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.*; import java.io.*; import java.lang.*; import java.math.*; public class C { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(bf.readLine()); int x1 ...
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.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public ...
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
h1,h2=input().split() u1,u2=input().split() h1,h2=int(h1),int(h2) u1,u2=int(u1),int(u2) n=int(input()) lis=[] for i in range(n): lis.append(input().split()) for i in range(n): for j in range(3): lis[i][j]=int(lis[i][j]) def status(a,b,lis): if a*lis[0]+b*lis[1]+lis[2]>0: return 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class ExtendedEuclid { static final double EPS = 1e-9; public static voi...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
import java.util.*; import java.io.*; import java.math.*; public class Class{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int x1 = Integer.parseI...
JAVA
498_A. Crazy Town
Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation aix + biy + ci = 0, where ai and bi are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block. We define an intersection as the po...
2
7
#include <bits/stdc++.h> const long long mod = 1e9 + 7; const long long INF = 9 * 1e18; using namespace std; void solve() { long long sx, sy, hx, hy, n, ans = 0, a, b, c; cin >> sx >> sy; cin >> hx >> hy; cin >> n; while (n--) { cin >> a >> b >> c; long long flag1 = 0, flag2 = 0; flag1 = a * sx + ...
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 CrazyTown { public static BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); public static StringTokenizer st; public static void main(String[] args) th...
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 = 1e5 + 5; const int inf = 1e9; const long long INF = 1e18; const double PI = acos(-1.0); const double EPS = 1e-8; const int MOD = 1000000007; struct Point { int x, y; Point() {} Point(int x, int y) : x(x), y(y) {} }; struct Line { int a, b, c; Line() ...
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 Solution{ static int mod=1000000007; public static void main(String[] args){ long x1 = longg(); long y1 = longg(); long x2 = longg(); long y2 = longg(...
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 xa, ya, xb, yb; cin >> xa >> ya >> xb >> yb; long long n, a, b, c, ch = 0; cin >> n; for (long long i = 0; 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
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; const int mod = 1e9 + 9; map<pair<int, int>, int> mp; pair<int, int> p[MAXN]; set<int> st; int num[MAXN]; long long fast_pow(long long x, int n) { long long ret = 1; while (n) { if (n & 1) { ret = ret * x % mod; } x = x * x % ...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; struct cube { long long ind, dl, dr, dd; }; vector<long long> sol, p; set<pair<long long, long long> > s; set<long long> canget; map<pair<long long, long long>, long long> goind; map<long long, pair<long long, long long> > gocoord; pair<long long, long long> t; vector<cub...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
import java.awt.geom.*; import java.io.*; import java.math.*; import java.util.*; import java.util.regex.*; import static java.lang.Math.*; public class B { public static final int MOD = 1000000009; long D = 1000000001; boolean invalid(Map<Long, Integer> map, long p) { long x = p/D; long y...
JAVA
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 100500; const int MOD = (int)1e9 + 9; int add(int a, int b) { a += b; if (a >= MOD) a -= MOD; return a; } int mul(int a, int b) { long long c = (long long)a * b; return (int)(c % MOD); } int n; pair<int, int> cube[N]; map<pair<int, int>, int> cube_to...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5; const long long M = 1e9 + 9; int n, x, y; pair<int, int> pos[N]; map<pair<int, int>, int> mp; set<int> q; long long ans; int children(int x, int y) { int ret = 0; for (int dx = -1; dx <= 1; dx++) { map<pair<int, int>, int>::iterator c = mp.find(ma...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; int n; long long ans; set<int> s; map<pair<int, int>, int> mp; pair<int, int> pos[100005]; inline int cnt(int x, int y) { int res = 0; for (int i = -1; i <= 1; i++) if (mp[make_pair(x + i, y - 1)] != 0) res++; return res; } inline bool can_ins...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 5; const int MOD = 1e9 + 9; set<pair<int, int> > Q[2]; pair<int, int> idd[MAX]; map<pair<int, int>, int> id; vector<int> lista; int dx[] = {-2, -1, 0, 1, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2}; int dy[] = {-1, -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 1}; int...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const long long INF = 1 << 28; const long long LINF = 1ll << 61; const long long mod = 1e9 + 9; inline int getval() { int __res = 0; bool __neg = 0; char __c; __c = getchar(); while (__c == ' ' || __c == '\n') __c = getchar(); while (__c != ' ' && __c != '\n') {...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; struct point { int x, y; int id; bool operator<(const point &b) const { if (y == b.y) return x < b.x; return y < b.y; } }; set<point> points_coord; vector<point> points; set<int> available; bool is_available(point &p) { point aux = p; aux.y++; if (poin...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; map<long long, int> MAP; long long MOD = 1e9 + 9; vector<pair<int, int> > inp; const int MAX = 1e5 + 5; set<int> FREE; int dx[3] = {-1, 0, +1}; int dy[3] = {-1, -1, -1}; int ONLY[MAX], depend[MAX]; void check(int id) { int cnt = 0, only; for (int i = 0; i < 3; i++) { ...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, int> mapa; set<int> S; vector<int> E[200000], I[200000]; int n; int X[200000], Y[200000]; int grau[200000]; vector<int> ans; int ja[200000]; void update(int i) { if (ja[i]) return; int mn = 2; for (int j = 0; j < E[i].size(); j++) { int viz = E...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int P = 1e9 + 9; const int N = 1e5 + 5; int n; int xx[N], yy[N]; map<pair<int, int>, int> cube; int isdanger[N], num[N], tree[N * 4]; int gett(pair<int, int> x) { if (cube.count(x)) return cube[x]; else return -1; } void add(int k, int m, int n, int x, int...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.HashMap; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.Map; import java.io.IOException; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.util...
JAVA
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.PrintStream; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; ...
JAVA
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
import java.util.NavigableSet; import java.util.TreeSet; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.InputStream; import java.util.HashMap; import java.util.NoSuchElementException; import java.util.Map; import java.io.OutputStreamWriter; import java.math.BigInteger; import jav...
JAVA
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; vector<long long> ans; pair<long long, pair<long long, long long>> ar[512345]; set<pair<long long, pair<long long, long long>>> sett; map<pair<long long, long long>, long long> mapp; void removenecessary(int x, int y) { for (int X = -1; X <= 1; ++X) { if (mapp.find(ma...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 9; const int maxn = 1e5 + 5; map<pair<int, int>, int> mp; set<int> st; bool ok[maxn] = {0}; int x[maxn], y[maxn]; int n, ans = 0; int get_id(int x, int y) { if (mp.find(pair<int, int>(x, y)) != mp.end()) return mp[pair<int, int>(x, y)]; return ...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, int> mp; int exists(pair<int, int> cube) { return mp.count(cube); } void del(pair<int, int> cube) { mp.erase(mp.find(cube)); } int countDependencies(pair<int, int> cube) { if (!exists(cube)) return 0; return exists({cube.first - 1, cube.second - 1}) ...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; int dx[] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dy[] = {0, -1, -1, -1, 0, 1, 1, 1}; const int N = 1000100; const long long mod = 1000000009LL; map<pair<long long, long long>, int> m; int n; vector<pair<long long, long long> > v; bool have(int x, int y) { if (m.find(pair<long ...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1e5 + 10; const int mod = 1e9 + 9; priority_queue<int> p, q; int N; int x[MAX_N], y[MAX_N]; int fr[MAX_N]; int res; map<pair<int, int>, int> G; int get_idx(int x, int y) { if (G.find({x, y}) != G.end()) return G[{x, y}]; return -1; } int count_bot(int ...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; map<pair<int, int>, int> m; int n, x[100005], y[100005]; long long ans; set<pair<int, int> > alive; set<int> s; set<int>::iterator it; void ins(pair<int, int> p) { if (!alive.count(p)) return; int k = m[p]; if (alive.count(make_pair(x[k] - 1, y[k] + 1))) if (!aliv...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
import java.io.*; import java.util.*; public class B extends PrintWriter { long point(long x, long y) { return x * 3334445556L + y; } boolean isStabel(int x, int y, EzLongIntHashMap p, int rx, int ry) { if (y == 0 || !p.containsKey(point(x, y))) { return true; } ...
JAVA
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
import java.util.TreeSet; import java.util.ArrayList; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.List; import java.io.BufferedReader; import java.util.Map; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util....
JAVA
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const long long mod = 1e9 + 9; int n, start = 1; int a[4 * N], ans[N]; vector<int> jos[N], sus[N]; map<pair<int, int>, int> m; struct punct { int x, y; } poz[N]; void Update(int nod) { a[nod] = max(a[nod + nod], a[nod + nod + 1]); if (nod > 1) U...
CPP
521_B. Cubes
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed upwards. Each cube is associated with the coordinates of its lower le...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.HashMap; import java.util.TreeSet; import java.util.ArrayList; import java.util.Map; import java.io.OutputStreamWriter; import java.io.OutputStream; import java.io.PrintStream; import java.io.I...
JAVA