Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define rip(i,a,b) for(int i = a;i<b;i++)
- using namespace std;
- void printV(vector<pair<int,int>> v){
- rip(i,0,v.size())cout << v[i].first<< " " << v[i].second<<endl;
- cout << endl;
- }
- int maxPoints(vector<string> points){
- stringstream s;
- vector<pair<int,int>>v;
- s << points[0];
- int n;s>>n;
- int x,y;
- for(int i = 1;i<n+1;i++){
- stringstream ss;
- ss << points[i];
- ss >> x >> y;
- v.push_back({y,x});
- }
- sort(v.begin(),v.end());
- int res = -1;
- set<int> m;
- m.insert(v[0].second);
- for(int i = 1;i<v.size();i++){
- if(v[i].first == v[i-1].first){
- //cout <<v[i].second<< " got here"<<endl;
- m.insert(v[i].second);
- }else{
- //cout << "LOL: " << m.count(0)<<endl;
- int c = 0;
- if(m.count(v[i].second))c++;
- for(int j = i+1;j<v.size();j++){
- if(v[j].first != v[j-1].first){
- res = max(res,c);
- c = 0;
- }
- //if(m[v[j].second])c++;
- if(m.count(v[j].second))c++;
- }
- res = max(res,c);
- m.clear();
- }
- m.insert(v[i].second);
- }
- return res;
- }
- int main(){
- int n;
- //cin >> n;
- cout << maxPoints({"20","24331 11582","40676 17095","36278 30532","41086 28684","20917 27058","12962 30532","12962 27058","12686 41706","11904 36954","36278 27058","20917 30532","28688 28593","37112 27058","18069 27058","32436 27058","37390 21596","18069 30532","27549 28756","32436 30532","37112 30532"});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement