Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <cmath>
- #include <utility>
- #include <bitset>
- #include <set>
- #include <string>
- #include <stack>
- #include <iomanip>
- #include <map>
- #define pb push_back
- #define F first
- #define S second
- #define LL long long
- #define mid (LB+RB)/2
- #define iter(x) x.begin(),x.end()
- /*
- 8e7 so dian
- FHVirus so dian
- youou so dian
- KYW so dian
- hubert so dian
- jass so dian
- tingyu so dian
- */
- //IO
- #include <iostream>
- #define theyRSOOOOOOOOODIAN ios_base::sync_with_stdio(false),cin.tie(0);
- #define endl '\n'
- //workspace
- #define pii pair<LL,LL>
- inline LL cross (pii o,pii a,pii b){
- return (a.F - o.F) * (b.S - o.S) - (a.S - o.S) * (b.F - o.F);
- }
- inline LL dot (pii o,pii a,pii b){
- return (a.F - o.F) * (b.F - o.F) + (a.S - o.S) * (b.S - o.S);
- }
- pii vo;
- inline bool cmp(pii a,pii b){
- if ((a.S - vo.S < 0) ^ (b.S - vo.S < 0))
- return a.S - vo.S >= 0;
- return cross(vo,a,b) <= 0;
- }
- inline void solve(int n){
- vector <pii> v;
- while (n--){
- int x,y;
- cin >> x >> y;
- v.pb({x,y});
- }
- vector <pii> sorted = v;
- int ans = 0;
- for (auto o:v){
- vo = o;
- sort (iter(sorted),cmp);
- vector <pair<pii,int>> it;
- bool exMinus = 0;
- if (sorted[0] != o)
- it.pb({sorted[0],1});
- else{
- it.pb({sorted[1],1});
- exMinus = 1;
- }
- for (int i=(sorted[0] != o ? 1 : 2);i<sorted.size();++i){
- if (sorted[i] == o){
- exMinus = 1;
- continue;
- }
- if ((sorted[i-1] != o && cross(o,sorted[i-1],sorted[i])) || (exMinus && cross(o,sorted[i-2],sorted[i])))
- it.pb({sorted[i],1});
- else
- ++it[it.size()-1].S;
- exMinus = 0;
- }
- for (int i=0,j=1;i<it.size();++i){
- //if (o.F == 0 && o.S == 1)
- //cout << it[i].F.F << ' ' << it[i].F.S << '\n';
- j = max(j,i+1);
- while (j+1 < i + it.size() && dot(o,it[i%it.size()].F,it[j%it.size()].F) > 0 && cross(o,it[i%it.size()].F,it[j%it.size()].F) < 0)
- ++j;
- if (!dot(o,it[i%it.size()].F,it[j%it.size()].F) && cross(o,it[i%it.size()].F,it[j%it.size()].F) < 0)
- ans += it[i%it.size()].S * it[j%it.size()].S;
- }
- //cout << o.F << ',' << o.S << ' ' << it.size() << ' ' << ans << '\n';
- }
- cout << ans << '\n';
- }
- int main(){
- theyRSOOOOOOOOODIAN
- int n;
- while (cin >> n && n) solve(n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement