Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cassert>
- #include <cctype>
- #include <climits>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <iostream>
- #include <sstream>
- #include <iomanip>
- #include <string>
- #include <vector>
- #include <list>
- #include <set>
- #include <map>
- #include <stack>
- #include <queue>
- #include <algorithm>
- #include <iterator>
- #include <utility>
- using namespace std;
- #define MP(x, y) make_pair(x, y)
- #define SET(p) memset(p, -1, sizeof(p))
- #define CLR(p) memset(p, 0, sizeof(p))
- #define MEM(p, v) memset(p, v, sizeof(p))
- #define CPY(d, s) memcpy(d, s, sizeof(s))
- #define SZ(c) (int)c.size()
- #define PB(x) push_back(x)
- #define ff first
- #define ss second
- #define ll long long
- #define ld long double
- #define mod 1000000007
- #define inf 1000000000
- typedef pair< double, double > pii;
- typedef pair< int, int > pll;
- typedef pair< string, int > psi;
- vector <pii> pnts;
- map <pii,ll> line;
- bool comp(pii a,pii b){
- double x = a.ss/a.ff;
- double y = b.ss/b.ff;
- if(x==y)return (a.ff*a.ff + a.ss*a.ss) < (b.ff*b.ff + b.ss*b.ss) ;
- return x<y;
- }
- ll solve(){
- sort(pnts.begin(),pnts.end(),comp);
- for(int i=0;i<pnts.size();i++){
- for(int j=i+1;j<pnts.size();j++){
- double m = (pnts[j].ss-pnts[i].ss)/(pnts[j].ff-pnts[i].ff);
- double c = (pnts[i].ss*pnts[j].ff-pnts[i].ff*pnts[j].ss)/(pnts[j].ff-pnts[i].ff);
- if(pnts[i].ff==pnts[j].ff){
- c=pnts[i].ff;
- }
- line[MP(m,c)]++;
- }
- }
- ll ans=0;
- for(map <pii,ll>::iterator it = line.begin();it!=line.end();it++){
- if(it->second){
- ll tem = it->second;
- ll x = 1+sqrt(1+8*tem);
- x/=2;
- //cout<<tem<<" "<<x<<endl;
- ans+=((x*(x-1)*(x-2))/6);
- }
- }
- //cout<<ans<<endl;
- return ans;
- }
- int main(int argc, char const *argv[])
- {
- ll n;
- cin>>n;
- ll ans = ((n*(n-1)*(n-2))/6);
- for(int i=0;i<n;i++){
- double x,y;
- cin>>x>>y;
- pnts.PB(MP(x+101,y+101));
- }
- ans-=solve();
- cout<<ans<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement