-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmorellets-random-lines.js
More file actions
24 lines (20 loc) · 896 Bytes
/
morellets-random-lines.js
File metadata and controls
24 lines (20 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const m2nums = _ => readline().split(' ').map(Number);
const [xA, yA, xB, yB] = m2nums();
const getY = (x, [a, b, c]) => b === 0 ? 1 : -((a * x + c) / b);
const getYs = (a) => [getY(xA, a), getY(xB, a)];
const redByMin = (a) => a.every(n => n % Math.min(...a) === 0) ? a.map(e => e / Math.min(...a)) : a;
const sameSign = (a) => a[0] < 0 ? a.map(n => -1 * n) : a;
var eqs = [...new Array(+readline())]
.map(m2nums)
.map(redByMin)
.map(sameSign)
.map(e => e.toString())
.map(e => e.split(',').map(Number))
.filter(( t={}, a=> !(t[a]=a in t) ));
let cntA = 0, cntB = 0;
eqs.map(getYs).forEach(([_yA, _yB]) => {
if (yA === _yA || yB === _yB) { print('ON A LINE'); quit(); }
if (yA > _yA) { cntA++; }
if (yB > _yB) { cntB++; }
})
print( (cntA % 2) === (cntB % 2) ? 'YES' : 'NO');