QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#796330 | #7906. Almost Convex | Mirasycle | WA | 0ms | 3624kb | C++14 | 1.5kb | 2024-12-01 16:54:32 | 2024-12-01 16:54:32 |
Judging History
answer
#include<bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
const int maxn=2e3+10;
//const double eps=-1e-9;
int n,R,vis[maxn],ans=1;
struct Point{
int x,y; int id;
Point(int xx=0,int yy=0,int ID=0){ x=xx; y=yy; id=ID; }
bool operator < (const Point rhs){ return x==rhs.x?y<rhs.y:x<rhs.x; }
}a[maxn],b[maxn];
typedef Point Vector;
Point operator - (Point p1,Point p2){ return Point(p1.x-p2.x,p1.y-p2.y,p1.id); }
ll Cross(Vector A,Vector B){ return 1ll*A.x*B.y-1ll*A.y*B.x; }//叉
bool cmp(Point p1,Point p2){
bool t1=(p1.y==0&&p1.x<0)||p1.y<0;
bool t2=(p2.y==0&&p2.x<0)||p2.y<0;
if(!t1&&t2) return 1;
if(t1&&!t2) return 0;
return (Cross(p1,p2)>0);
}
vector<Point> convex(){
vector<Point> qs; sort(a+1,a+1+n);
qs.resize(2*n); int k=0;
for(int i=1;i<=n;qs[k++]=a[i++])
while(k>1&&Cross(qs[k-1]-qs[k-2],a[i]-qs[k-1])<=0) k--;
for(int i=n-1,t=k;i>=1;qs[k++]=a[i--])
while(k>t&&Cross(qs[k-1]-qs[k-2],a[i]-qs[k-1])<=0) k--;
qs.resize(k-1); return qs;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y,a[i].id=i;;
vector<Point> H=convex();
for(auto v:H) vis[v.id]=1;
for(int i=1;i<=n;i++){
if(vis[a[i].id]) continue; int cnt=0;
for(int j=1;j<=n;j++)
if(i!=j) b[++cnt]=Point(a[j]-a[i]);
sort(b+1,b+1+cnt);
for(int i=1;i<cnt;i++)
if(vis[b[i].id]&&vis[b[i+1].id]) ans++;
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
input:
7 1 4 4 0 2 3 3 1 3 5 0 0 2 4
output:
7
result:
wrong answer 1st numbers differ - expected: '9', found: '7'