Submission #523435

# Submission time Handle Problem Language Result Execution time Memory
523435 2022-02-07T16:07:13 Z tato Geometrija (COCI21_geometrija) C++14
0 / 110
1 ms 296 KB
#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
1 Incorrect 1 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -