This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fs first
#define sc second
#define pii pair<int,int>
using namespace std;
pii a[1001];
int check(pii vect, pii pt, pii npt)
{
int A = vect.sc;
int B = (-1)*vect.fs;
int C = (-1)*A*(pt.fs) - B*(pt.sc);
if((A*npt.fs + B*npt.sc + C) > 0)
return 1;
else
if((A*npt.fs + B*npt.sc + C) < 0)
return 2;
else
return 0;
}
void answer()
{
int n;
int cnt = 0;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i].fs >> a[i].sc;
for(int i = 1; i < n; i++)
{
for(int j = i + 1; j <= n; j++)
{
pii vect ;
vect.fs = a[i].fs - a[j].fs;
vect.sc = a[i].sc - a[j].sc;
int indx1 = 0, indy1 = 0, ind_x1 = 0, ind_y1 = 0;
for(int k = 1; k <= n; k++)
{
int ind = check(vect, a[i], a[k]);
if((a[i].fs <= a[k].fs and a[j].fs >= a[k].fs) or (a[i].fs >= a[k].fs and a[j].fs <= a[k].fs))
{
if(ind == 1)
indx1 = 1;
if(ind == 2)
ind_x1 = 1;
}
if((a[i].sc <= a[k].sc and a[j].sc >= a[k].sc) or (a[i].sc >= a[k].sc and a[j].sc <= a[k].sc))
{
if(ind == 1)
indy1 = 1;
if(ind == 2)
ind_y1 = 1;
}
}
if((indx1 == 0 or ind_x1 == 0) and (indy1 == 0 or ind_y1 == 0))
cnt++;
}
}
cout << cnt;
}
int main()
{
int t = 1;
//cin >> t;
while(t--)
answer();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |