Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define qio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  3. #define debug(x) cerr<<#x<<" "<<x<<endl
  4. #define ll long long
  5. #define st first
  6. #define nd second
  7. using namespace std;
  8.  
  9. int n,t,x,it,it2;
  10. string s,a,b,fa,fb,tempa,tempb;
  11. vector <pair<string,string>> V;
  12. int main()
  13. {
  14. qio;
  15. while(getline(cin,s)){
  16. x=0;
  17. a.clear();
  18. b.clear();
  19. fa.clear();
  20. fb.clear();
  21. for(int i = 0 ; i<s.size() ; i++){
  22. if(s[i]=='-') x=1;
  23. else if(s[i]!=' '&& x==0){
  24. a+=s[i];
  25. }
  26. else if(s[i]!=' '){
  27. b+=s[i];
  28. }
  29. }
  30. for(int i = a.size() ; i<18 ; i++){
  31. fa+='0';
  32. }
  33.  
  34. for(int i = b.size() ; i<18 ; i++){
  35. fb+='0';
  36. }
  37. it = 18-a.size();
  38. it2= 18-b.size();
  39. for(int i = 0 ; i<a.size() ; i++){
  40. fa+=a[i];
  41. if(i+it+1==10) fa+=' ';
  42. }
  43.  
  44. for(int i = 0 ; i<b.size() ; i++){
  45. fb+=b[i];
  46. if(i+it2+1==10) fb+=' ';
  47. }
  48. V.push_back({fa,fb});
  49. }
  50. sort(V.begin(),V.end());
  51. tempa=V[0].first;
  52. tempb=V[0].second;
  53. for(int i = 1 ; i<V.size() ; i++){
  54. if(V[i].first<=tempb){
  55. tempb=max(V[i].second,tempb);
  56. }
  57. else{
  58. cout<<tempa<<" - "<<tempb<<endl;
  59. tempb=V[i].second;
  60. tempa=V[i].first;
  61. }
  62. }
  63. cout<<tempa<<" - "<<tempb<<endl;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement