hihoCoder太阁最新面经算法竞赛19 register

Ended

Participants:128

Verdict:Accepted
Score:100 / 100
Submitted:2016-12-18 18:27:49

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int Area2(long x0, long y0, long x1, long y1, long x2, long y2) {
  auto ret = x0  * (y1 - y2) - y0 * (x1 - x2) + x1 * y2 - x2 * y1;
  return ret < 0 ? -ret : ret;
}
int main() {
    int t;
    cin >> t;
    while (t-- > 0) {
      int px, py, ax, ay, bx, by, cx, cy;
      cin >> px >> py >> ax >> ay >> bx >> by >> cx >> cy;
      auto eq = Area2(ax, ay, bx, by, cx, cy) ==
                Area2(ax, ay, bx, by, px, py) +
                Area2(ax, ay, px, py, cx, cy) +
                Area2(px, py, bx, by, cx, cy);
      cout << (eq ? "YES" : "NO") << endl;
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX