# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
234998 | Pajaraja | 별자리 2 (JOI14_constellation2) | C++17 | 1060 ms | 692 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MAXN 3007
using namespace std;
struct point {
long long x,y;
int ind,c;
};
long long cnn[3],cnp[3];
int n;
point a[MAXN];
vector<pair<point,bool>> u;
long long orient(point p,point q,point r)
{
return (q.x-p.x)*(r.y-p.y)-(q.y-p.y)*(r.x-p.x);
}
bool operator <(point p,point q)
{
return orient(p,q,a[0])>0;
}
int main()
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%lld%lld%d",&a[i].x,&a[i].y,&a[i].c);
a[i].ind=i;
}
long long res=0;
for(int i=0;i<n;i++)
{
swap(a[i],a[0]);
u.clear();
for(int j=1;j<n;j++)
{
if(a[j].x>=a[0].x) u.push_back({a[j],true});
else
{
point f; f.x=2*a[0].x-a[j].x; f.y=2*a[0].y-a[j].y; f.ind=a[i].ind; f.c=a[j].c;
u.push_back({f,false});
}
}
sort(u.begin(),u.end());
for(int j=0;j<3;j++) cnp[j]=cnn[j]=0;
for(int j=0;j<u.size();j++)
{
if(u[j].second) cnp[u[j].first.c]++;
else cnn[u[j].first.c]++;
}
for(int j=0;j<u.size();j++)
{
if(u[j].second) cnp[u[j].first.c]--;
else cnn[u[j].first.c]--;
long long t1=1,t2=1,t3=1,t4=1;
for(int z=0;z<3;z++) if(a[0].c!=z) t1*=cnp[z];
for(int z=0;z<3;z++) if(a[0].c!=z) t2*=cnn[z];
for(int z=0;z<3;z++) if(u[j].first.c!=z) t3*=cnp[z];
for(int z=0;z<3;z++) if(u[j].first.c!=z) t4*=cnn[z];
res+=(t1*t4+t2*t3);
if(!u[j].second) cnp[u[j].first.c]++;
else cnn[u[j].first.c]++;
}
}
//assert(res%4==0);
res=res/4LL;
printf("%lld",res);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |