QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#312777#7730. Convex Checkerred_jiuWA 62ms14816kbC++233.9kb2024-01-24 11:59:452024-01-24 11:59:45

Judging History

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

  • [2024-07-04 19:27:17]
  • hack成功,自动添加数据
  • (/hack/727)
  • [2024-07-04 19:17:30]
  • hack成功,自动添加数据
  • (/hack/726)
  • [2024-01-24 11:59:45]
  • 评测
  • 测评结果:WA
  • 用时:62ms
  • 内存:14816kb
  • [2024-01-24 11:59:45]
  • 提交

answer

/*

_/_/_/_/     _/      _/    _/
_/     _/    _/      _/    _/
_/      _/   _/      _/    _/
_/      _/   _/_/_/_/_/    _/
_/     _/    _/      _/    _/
_/    _/     _/      _/    _/
_/_/_/       _/      _/    _/_/_/_/_/

*/
#include<bits/stdc++.h>
using namespace std;
typedef   long long ll;
typedef double LD;
constexpr ll P = 1e9;
const int N = 1e5 + 50;
const int M = 500010;
const double PI = acos(-1);
const LD eps = 1e-8;
#define INF  10000000007
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll  Exgcd(ll a, ll b, ll& x, ll& y) {
	if (!b)
	{
		x = 1, y = 0;
		return a;
	}
	ll d = Exgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
ll n, m, k, x, y, z, l, r, u, v, w;
ll   cnt1, res, anss1, anss, sum[M];
string  s, ss, sss;
ll  p, t, rr;
char xx;
vector<ll>vv[M];
ll b[M], d[M][3], ans, summ[M];
ll a[M][3];
struct point {
	LD x, y;
	point operator + (const point& a) const { return { x + a.x, y + a.y }; }
	point operator - (const point& a) const { return { x - a.x, y + a.y }; }
	point operator * (const LD a) const { return { x * a, y * a }; }
};
struct line {
	point s, t;
};
int sgn(LD x) {
	return x > eps ? 1 : (x < -eps ? -1: 0);
}
LD dot(const point& a, const point& b) {
	return a.x * a.x + a.y * a.y;
}
LD det(const point& a, const point& b) {
	return a.x * b.y - b.x * a.y;
}
bool turn_left(const point& a,
	const point& b,
	const point& c) {
	return sgn(det(b - a, c - a)) > 0;
}
bool cmp(point x, point y)
{
	return (x.x < y.x) || (x.x == y.x && x.y < y.y);
}
vector <point> convex_hull(vector <point> a) {
	if (a.size() <= 2) return a; //或 者 return {};
	sort(a.begin(), a.end(),cmp); //字 典 序: less <pair >
	vector <point > ret;
	for (int i = 0; i < (int)a.size(); i++) {
		while (ret.size() > 1
			&& !turn_left(ret[ret.size() - 2], ret[ret.size() - 1], a[i]))
			ret.pop_back();
		ret.push_back(a[i]);

	}
	int fixed = (int)ret.size();
	for (int i = (int)a.size() - 2; i >= 0; --i) {
		while (ret.size() > fixed
			&& !turn_left(ret[ret.size() - 2], ret[ret.size() - 1], a[i]))
			ret.pop_back();
		ret.push_back(a[i]);
	}
	ret.pop_back(); return ret; //或 者 在 ret.size() <= 2 时 return {};

}
void solve()
{
	cin >> n;
	vector<point>a;
	for (int i = 1; i <= n; i++)
	{
		cin >> x >> y;
		point z = { x,y };
		a.push_back(z);
	}
	vector<point> vv;
	vv = convex_hull(a);
	map<pair<LD, LD>, ll>mp;
	ll ans = 0;
	for (auto x : vv)
	{
		mp[{x.x, x.y}]++;
		if (mp[{x.x, x.y}] == 1)
		{
			ans++;
		}
	}
	if ( ans== n)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int T = 1;
	//cin >> T;
	while (T--)
	{
		solve();
	}
	return 0;
}


//ll pri[M], st[M], phi[M];
//void is_prime(ll n)
//{
//	phi[1] = 1;
//	for (register int i = 2; i <= n; i++)
//	{
//		if (!st[i])pri[++cnt] = i, phi[i] = i - 1;
//		for (int j = 1; j <= cnt && pri[j] <= n / i; j++)
//		{
//			st[pri[j] * i] = 1;
//			if (i % pri[j] == 0)
//			{
//				phi[i * pri[j]] = phi[i] * pri[j];
//				break;
//			}
//			else
//			{
//				phi[i * pri[j]] = phi[i] * phi[pri[j]];
//			}
//		}
//	}
//}


//int bsgs(int a, int b, int p)
//{
//	int k = sqrt(p) + 1;
//	unordered_map<int, int>mp
//	for (int i = 0, j = b % p; i < k; i++)
//	{
//		mp[j] = i;
//		j = 1LL * j * a % p;
//	}
//	int ak = fpm(a, k, p);
//	for (int i = 1, j = ak % p; i <= k; i++)
//	{
//		if (mp.count(j))return 1LL * i * k - mp[j];
//		j = 1LL * j * ak % p;
//	}
//	return-2;
//}
//int exbsgs(int a, int b, int p)
//{
//	b = (b % p + p) % p;
//	if (1 % p == b % p)return 0;
//	int d = Exgcd(a, p, x, y);
//	if (d > 1)
//	{
//		if (b % d) return -INF;
//		Exgcd(a / d, p / d, x, y);
//		return exbsgs(a, b / d * x % (p / d), p / d) + 1;
//	}
//	else
//	{
//		return bsgs(a, b, p);
//	}
//}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3792kb

input:

3
0 0
1 0
0 1

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 1ms
memory: 3540kb

input:

4
0 0
0 1
1 1
1 0

output:

Yes

result:

ok answer is YES

Test #3:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

4
0 0
0 3
1 2
1 1

output:

Yes

result:

ok answer is YES

Test #4:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

3
0 0
0 0
0 0

output:

No

result:

ok answer is NO

Test #5:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

5
1 0
4 1
0 1
2 0
3 2

output:

No

result:

ok answer is NO

Test #6:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

5
0 0
1000000000 0
1000000000 500000000
1000000000 1000000000
0 1000000000

output:

No

result:

ok answer is NO

Test #7:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

5
0 0
1000000000 0
1000000000 499999999
1000000000 1000000000
0 1000000000

output:

No

result:

ok answer is NO

Test #8:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

5
0 0
999999999 0
1000000000 50000000
999999999 1000000000
0 1000000000

output:

Yes

result:

ok answer is YES

Test #9:

score: -100
Wrong Answer
time: 62ms
memory: 14816kb

input:

128312
5578014 410408218
5585076 410404717
5588011 410403262
5588473 410403033
5589740 410402405
5593295 410400643
5593751 410400417
5597248 410398684
5598935 410397848
5600618 410397014
5605185 410394751
5610514 410392111
5614281 410390245
5617263 410388768
5621142 410386847
5630840 410382045
56310...

output:

No

result:

wrong answer expected YES, found NO