Advertisement
Falak_Ahmed_Shakib

struct+sort+ comnpera

Apr 6th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 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(node &a,node &b){
  37. if(a.x==b.x)return a.y<b.y;
  38.  
  39. return a.x<b.x;
  40.  
  41. }
  42.  
  43. int main()
  44. {
  45.  
  46. ll n;
  47.  
  48. cin>>n;
  49.  
  50. /// vector<node>v;
  51.  
  52. vector<node>v(n);
  53.  
  54.  
  55. for(ll i=0;i<n;i++)
  56. {
  57. cin>>v[i].x>>v[i].y>>v[i].name;
  58.  
  59.  
  60. ///ll a,b; string c;cin>>a>>b>>c;v.push_back(node{a,b,c});
  61.  
  62. }
  63.  
  64. sort(v.begin(),v.end(),compare);
  65.  
  66.  
  67. for(ll i=0;i<n;i++)
  68. {
  69. cout<<v[i].x<<" "<<v[i].y<<" "<<v[i].name<<endl;
  70. }
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement