fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef pair<long double, int> p;
  6.  
  7. bool compare(p a, p b){
  8. return a.first < b.first;
  9. }
  10.  
  11. int main(){
  12. vector<p> testing;
  13. int n;
  14. cin>>n;
  15. for(int i=1; i<=n; i++){
  16. long double x,y;
  17. cin>>x>>y;
  18. testing.push_back(make_pair(atan2(y,x),i));
  19. }
  20.  
  21. sort(testing.begin(), testing.end(), compare);
  22. // for(int i=0; i<testing.size(); i++){
  23. // cout<<testing[i].first<<" "<<testing[i].second<<endl;
  24. // }
  25.  
  26.  
  27. long double minDif = 10;
  28. pair<int,int> ans;
  29.  
  30. for(int i=1; i<testing.size(); i++){
  31. long double tempDif = abs(testing[i].first - testing[i-1].first);
  32. if(tempDif < minDif){
  33. minDif = tempDif;
  34. ans = make_pair(testing[i].second, testing[i-1].second);
  35. }
  36. }
  37.  
  38. cout<<ans.first<<" "<<ans.second<<endl;
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
0 0