QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#554583#7906. Almost Convexliqingyang#WA 287ms3704kbC++141.7kb2024-09-09 12:27:082024-09-09 12:27:08

Judging History

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

  • [2024-09-09 12:27:08]
  • 评测
  • 测评结果:WA
  • 用时:287ms
  • 内存:3704kb
  • [2024-09-09 12:27:08]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
struct point
{
	int x,y;
};
inline bool operator <(const point &a,const point &b)
{
	return a.x==b.x?a.y<b.y:a.x<b.x;
}
inline point operator -(const point &a,const point &b)
{
	return {a.x-b.x,a.y-b.y};
}
inline long long operator *(const point &a,const point &b)
{
	return (long long)a.x*b.y-(long long)a.y*b.x;
}
int n,head,sta[2010],num,p[2010];
point a[2010],A;
bool mark[2010],Mark[2010];
vector<int> v;
inline bool cmp(int x,int y)
{
	return (a[x]-A)*(a[y]-A)>0;
}
inline bool in(int x,int y,int z)
{
	return ((a[p[x]]-A)*(a[z]-A)>0)
	==((a[z]-A)*(a[p[y]]-A)>0);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].x>>a[i].y;
	}
	sort(a+1,a+n+1),sta[head=1]=1;
	for(int i=2;i<=n;i++)
	{
		while(head>1&&(a[sta[head]]-a[sta[head-1]])
		*(a[i]-a[sta[head-1]])>0)
		{
			head--;
		}
		sta[++head]=i;
	}
	num=head,memcpy(p,sta,sizeof(p));
	sta[head=1]=n;
	for(int i=n-1;i;i--)
	{
		while(head>1&&(a[sta[head]]-a[sta[head-1]])
		*(a[i]-a[sta[head-1]])>0)
		{
			head--;
		}
		sta[++head]=i;
	}
	for(int i=2;i<=head;i++)
	{
		p[++num]=sta[i];
	}
	for(int i=1;i<=num;i++)
	{
		mark[p[i]]=1;
	}
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		if(mark[i])
		{
			continue;
		}
		A=a[i],v.clear();
		for(int j=1;j<=n;j++)
		{
			if(i==j||!mark[j])
			{
				v.emplace_back(j);
			}
		}
		sort(v.begin(),v.end(),cmp);
		memset(Mark,0,sizeof(Mark));
		for(int j=0,k=1;j<v.size();j++)
		{
			while(!in(k,k+1,v[j]))
			{
				k=k+1<num?k+1:1;
			}
			Mark[k]=1;
		}
		for(int j=1;j<num;j++)
		{
			ans+=!Mark[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

7
1 4
4 0
2 3
3 1
3 5
0 0
2 4

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

5
4 0
0 0
2 1
3 3
3 1

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

3
0 0
3 0
0 3

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

6
0 0
3 0
3 2
0 2
1 1
2 1

output:

7

result:

ok 1 number(s): "7"

Test #5:

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

input:

4
0 0
0 3
3 0
3 3

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: -100
Wrong Answer
time: 287ms
memory: 3704kb

input:

2000
86166 617851
383354 -277127
844986 386868
-577988 453392
-341125 -386775
-543914 -210860
-429613 606701
-343534 893727
841399 339305
446761 -327040
-218558 -907983
787284 361823
950395 287044
-351577 -843823
-198755 138512
-306560 -483261
-487474 -857400
885637 -240518
-297576 603522
-748283 33...

output:

46245

result:

wrong answer 1st numbers differ - expected: '718', found: '46245'