QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673718#7730. Convex CheckerYansuan_HClWA 0ms3704kbC++201.5kb2024-10-25 09:20:452024-10-25 09:20:46

Judging History

你现在查看的是最新测评结果

  • [2024-10-25 09:20:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3704kb
  • [2024-10-25 09:20:45]
  • 提交

answer

#include <bits/stdc++.h>
#define ms(x, v) memset(x, v, sizeof(x))
#define il __attribute__((always_inline)) static
#define U(i,l,r) for(int i(l),END##i(r);i<=END##i;++i)
#define D(i,r,l) for(int i(r),END##i(l);i>=END##i;--i)
using namespace std;
using ll = long long;

#define IC isdigit(c)
#define GC c=getchar()
void rd(auto &x) { x = 0; char GC; bool f = 0;
	for (; !IC; GC) f |= c == '-';
	for (; IC; GC) x = x * 10 + c - 48;
	if (f) x = -x;
}
void rd(auto &x, auto &...y) { rd(x); rd(y...); }
#define meow(...) fprintf(stderr, __VA_ARGS__)
#define Assert(e, v) if (!(e)) { meow("AF@%d\n", __LINE__ ); exit(v); }

#define vc vector
#define eb emplace_back
#define pb push_back

void no() { puts("No"); exit(0); }

const int N = 200005;
int n;
using pt = complex<ll>;
#define X real()
#define Y imag()
ll cross(pt l, pt r) { return l.X * r.Y - l.Y * r.X; }

pt a[N];

int main() {
//	freopen("ava.in", "r", stdin);
	
	rd(n);
	U (i, 1, n) {
		ll x, y; rd(x, y);
		a[i] = {x, y};
	}
	sort(a + 1, a + n + 1, [&](pt u, pt v) {
		return u.X == v.X ? u.Y < v.Y : u.X < v.X; });
	U (i, 2, n)
		if (a[i] == a[i - 1]) 
			no();
	D (i, n, 1) a[i] -= a[1];
	sort(a + 2, a + n + 1, [&](pt u, pt v) {
		ll x = cross(u, v);
		return x == 0 ? u.X < v.X : (x < 0);
	});
//	U (i, 1, n) {
//		clog << a[i].X << ' ' << a[i].Y << endl;
//	}
	U (i, 1, n) {
		int j = i % n + 1, k = (i + 1) % n + 1;
		if (cross(a[j] - a[i], a[k] - a[j]) >= 0)
			no();
	}
	puts("Yes");
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3664kb

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

4
0 0
0 1
1 1
1 0

output:

Yes

result:

ok answer is YES

Test #3:

score: 0
Accepted
time: 0ms
memory: 3704kb

input:

4
0 0
0 3
1 2
1 1

output:

Yes

result:

ok answer is YES

Test #4:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

5
1 0
4 1
0 1
2 0
3 2

output:

Yes

result:

wrong answer expected NO, found YES