Untitled
unknown
plain_text
2 years ago
1.9 kB
6
Indexable
#include <bits/stdc++.h> using namespace std; long long int n, x, y, ans1, ans2, ans3, X[250005], Y[250005], f[250005], cnt1, cnt2, nrelim, cnt, poz, nr0; vector<pair<int, int> > v; //vector<int> X, Y; bool cmp(pair<int, int> x, pair<int, int> y){ return (x.first<y.first) || (x.first==y.first && x.second<y.second); } int main(){ ifstream fin("puncte1.in"); ofstream fout("puncte1.out"); fin>>n; for(int i=0; i<n; i++){ fin>>x>>y; v.push_back({x, y}); if(x<0){ x*=-1; x+=1000; } if(y<0){ y*=-1; y+=1000; } X[x]++; Y[y]++; } sort(v.begin(), v.end(), cmp); for(int i=0; i<=1999; i++){ if(X[i]>ans1){ ans1=X[i]; } } for(int i=0; i<=1999; i++){ if(Y[i]>ans1){ ans1=Y[i]; } } fout<<ans1<<endl; for(int i=0; i<n; i++){ if(v[i].first==v[i].second){ //fout<<v[i].first<<endl; if(v[i].first==0){ nr0=1; } else{ cnt1++; } } if(v[i].first+v[i].second==0 && v[i].first!=0 && v[i].second!=0){ cnt2++; //fout<<v[i].first<<" "<<v[i].second<<endl; } } if(cnt1==0 && cnt2==0 || (cnt1+cnt2<2 && nr0==0)){ fout<<0<<endl; } else if(cnt1+nr0>1 && cnt2+nr0>1){ fout<<cnt1*cnt2+2<<endl; } else{ fout<<cnt1*cnt2+1<<endl; } //fout<<cnt1<<" "<<cnt2<<" "<<nr0<<endl; while(nrelim<n-1){ for(int i=0; i<n; i++){ if(f[i]==0){ cnt++; if(cnt==3 && nrelim<n-1){ f[i]=1; cnt=0; nrelim++; } } } } for(int i=0; i<n; i++){ if(f[i]==0){ ans3=v[i].first; break; } } fout<<ans3; return 0; }
Editor is loading...