Advertisement
Falak_Ahmed_Shakib

vector +( pair pair and pair)

Apr 1st, 2020
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 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)
  32. {
  33. for(ll i=0; i<n; i++)
  34. cin>>ara[i];
  35. }
  36.  
  37. void output(ll ara[],ll n)
  38. {
  39. for(ll i=0; i<n; i++)
  40. cout<<ara[i]<<" ";
  41. }
  42.  
  43. ll mx1(ll ara[],ll n)
  44. {
  45. ll mx=-1;
  46. for(ll i=0; i<n; i++)
  47. if(ara[i]>mx)
  48. mx=ara[i];
  49. return mx;
  50. }
  51. ll mn1(ll ara[],ll n)
  52. {
  53. ll mn=1e18;
  54. for(ll i=1; i<=n; i++)
  55. if(ara[i]<mn)
  56. mn=ara[i];
  57. return mn;
  58. }
  59.  
  60. #define eb emplace_back
  61.  
  62.  
  63. int main()
  64. {
  65. fastread();
  66.  
  67. ll t;
  68. ll kase=1;
  69.  
  70. cin>>t;
  71.  
  72. while(t--)
  73. {
  74. ll n;
  75.  
  76.  
  77. cin>>n;
  78.  
  79.  
  80.  
  81. vector<pair<ll,pair<ll,ll>>>v;
  82.  
  83. for(ll i=0;i<n;i++)
  84. {
  85.  
  86.  
  87. ll a,b;
  88.  
  89. cin>>a>>b;
  90.  
  91.  
  92. v.push_back({a,{b,i}});
  93.  
  94.  
  95. }
  96.  
  97.  
  98. sort(v.begin(),v.end());
  99.  
  100.  
  101.  
  102. for(ll i=0;i<n;i++)
  103. {
  104.  
  105.  
  106. cout<<v[i].first<<" ";
  107.  
  108.  
  109. cout<<v[i].second.first<<" ";
  110. cout<<v[i].second.second<<endl;
  111.  
  112.  
  113. }
  114.  
  115. ll j=0,c=0;
  116. bool f=true;
  117. char ara[n+1];
  118.  
  119. for(ll i=0;i<n;i++)
  120. {
  121. if(v[i].first>=j )
  122. {
  123. ara[v[i].second.second]='J';
  124. j=v[i].second.first;
  125.  
  126. }else if(v[i].first>=c )
  127. {
  128. ara[v[i].second.second]='C';
  129. c=v[i].second.first;
  130. }else
  131. {
  132. f=false ;
  133.  
  134. break;
  135. }
  136.  
  137. }
  138.  
  139. cout<<"Case #<<"<<kase++<<": ";
  140. if(f)
  141. {
  142. for(ll i=0;i<n;i++)
  143. {
  144. cout<<ara[i];
  145. }
  146. cout<<endl;
  147.  
  148. }
  149. else cout<<"IMPOSSIBLE"<<endl;
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158. }
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement