Falak_Ahmed_Shakib

vector +pair +sort +compere+ struct-ara

Apr 6th, 2020 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. // In the name of Allah.
  2. // We're nothing and you're everything.
  3. // Ya Ali!
  4. /*
  5. , \ / ,
  6. / \ )\__/( / \
  7. / \ (_\ /_) / \
  8. ____/_____\__\@ @/___/_____\____
  9. | |\../| |
  10. | \VV/ |
  11. | ------___------- |
  12. |__________Chuta Dragon___________|
  13. | /\ / \\ \ /\ |
  14. | / V )) V \ |
  15. |/ ` // ' \|
  16. ` V '
  17. */
  18.  
  19. #include<bits/stdc++.h>
  20. using namespace std;
  21. typedef long long ll;
  22. typedef pair<ll,ll>pll;
  23. #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
  24. #define fi first
  25. #define se second
  26. #define pb push_back
  27. ll const MOD=1000000007;
  28. ///-------------------------------------------------------------------------------------------------///
  29. /// KARMA IS LIKE 69,,, YOU GET WHAT YOU GIVE ///
  30. ///-------------------------------------------------------------------------------------------------///
  31. void input(ll ara[],ll n){ for(ll i=0; i<n; i++)cin>>ara[i];}
  32. #define eb emplace_back
  33.  
  34. typedef struct{ll x,y;string name;}node;
  35.  
  36. bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
  37.  
  38. if(a.fi==b.fi)return a.se<b.se;
  39.  
  40. return a.first<b.first;
  41.  
  42. }
  43.  
  44. int main()
  45. {
  46.  
  47. ll n;
  48.  
  49.  
  50. cin>>n;
  51.  
  52.  
  53. vector<pair<ll,ll>>v(n);
  54.  
  55.  
  56. for(ll i=0;i<n;i++)
  57. {
  58. cin>>v[i].fi>>v[i].se;
  59. }
  60.  
  61. sort(v.begin(),v.end(),compare);
  62.  
  63. for(ll i=0;i<n;i++)
  64. {
  65.  
  66.  
  67. cout<<v[i].fi<<" "<<v[i].se<<endl;
  68.  
  69. }
  70.  
  71.  
  72.  
  73.  
  74. }
  75. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  76.  
  77. struct nod{
  78. ll s,f,p;
  79. };
  80. bool com(nod a,nod b)
  81. {
  82. return a.f<b.f;
  83. }
Add Comment
Please, Sign In to add comment