QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#398391#3769. 共线点Hjcc#AC ✓5ms3596kbC++141.5kb2024-04-25 11:27:562024-04-25 11:27:56

Judging History

This is the latest submission verdict.

  • [2024-04-25 11:27:56]
  • Judged
  • Verdict: AC
  • Time: 5ms
  • Memory: 3596kb
  • [2024-04-25 11:27:56]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long
inline int dcmp(ll a) {
  return a < 0 ? -1 : (a > 0 ? 1 : 0);
}
inline ll Abs(ll a) {
  return a * dcmp(a);
}
struct Dis {
  ll x, y;
  Dis(ll X = 0, ll Y = 0) { x = X, y = Y; }
};

ll operator *(Dis x, Dis y) {
  return x.x * y.y - x.y * y.x;
}

Dis operator -(Dis x, Dis y) {
  return {x.x - y.x, x.y - y.y};
}

struct Len {
  Dis x, y;
};

ll operator *(Len x, Len y) {
  return (x.y - x.x) * (y.y - y.x);
}

bool ck(ll x, ll y) {
  return dcmp(x) * dcmp(y) >= 0;
}

bool X(Len x, Len y) {
  return ck((y.y - x.x) * (x.y - x.x), (x.y - x.x) * (y.x - x.x)) && ck((x.x - y.x) * (y.y - y.x), (y.y - y.x) * (x.y - y.x));
}

bool sov(Len x, Len y, Dis z) {
  return  ck((y.x - x.x) * (z - x.x), (x.y - y.y) * (z - y.y));
}

bool clc(Len x, Len y, Len z) {
  if (X(x, y)) {
    return 1;
  }
  if (sov(x, y, z.x) || sov(x, y, z.y)) {
    return 1;
  }
  swap(x.x, x.y);
  return sov(x, y, z.x) || sov(x, y, z.y);
}

bool pr(Len x, Len y, Len z) {
  return clc(x, y, z) || clc(y, z, x) || clc(z, x, y);
}

ll a1, b1, Y1, a2, b2, Y2, a3, b3, Y3;

int main() {
# ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
# endif
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  while (cin >> a1 >> b1 >> Y1 >> a2 >> b2 >> Y2 >> a3 >> b3 >> Y3) {
    cout << (pr({{a1, Y1}, {b1, Y1}}, {{a2, Y2}, {b2, Y2}}, {{a3, Y3}, {b3, Y3}}) ? "Yes\n" : "No\n");
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 3596kb

input:

0 1 0
0 1 1
0 1 2
0 1 0
1 2 1
0 1 2
0 1 0
2 3 1
0 1 2
3 8 2
5 7 4
2 8 7
2 7 1
1 3 3
0 8 4
4 6 1
1 3 3
2 9 4
0 9 1
0 3 6
2 9 9
0 6 3
4 6 5
1 2 7
6 9 4
4 7 6
1 8 9
0 6 5
0 6 6
0 8 7
4 7 2
6 8 4
2 5 8
5 6 1
6 9 2
1 5 9
3 5 1
2 8 2
3 4 6
5 8 2
1 6 3
8 9 7
1 7 2
4 7 6
2 9 9
5 6 3
0 7 5
2 4 8
0 3 1
2 9 3
...

output:

Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Y...

result:

ok 10000 lines