Advertisement
Guest User

Solution 1

a guest
Nov 11th, 2019
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using String = std::string;
  6.  
  7.  
  8. // Check Examples
  9.  
  10.  
  11. //Compiler version g++ 6.3.0
  12.  
  13. struct Shoe
  14. {
  15.     unsigned short size;
  16.     unsigned char orientation;
  17.     bool paired = false;
  18.    
  19.     Shoe()
  20.     {
  21.         std::cin >> size;
  22.         std::cin >> orientation;
  23.        
  24.         if(size >= 100) size = 99;
  25.     }
  26.    
  27.     bool operator==(Shoe& otherShoe)
  28.     {
  29.         if(otherShoe.paired) return false;
  30.         if(orientation == otherShoe.orientation) return false;
  31.         if(size != otherShoe.size) return false;
  32.        
  33.         paired = true;
  34.         otherShoe.paired = true;
  35.         return true;
  36.     }
  37. };
  38.  
  39. int main()
  40. {
  41.     std::vector<Shoe> shoes;
  42.     unsigned short N;
  43.     std::cin >> N;
  44.    
  45.     for(unsigned short i=0;i < N ;i++)
  46.     {
  47.         shoes.push_back(Shoe());
  48.     }
  49.    
  50.     for(Shoe& e:shoes)
  51.     {
  52.         if(e.paired) continue;
  53.        
  54.         for(Shoe& x:shoes)
  55.             if(e == x) break;
  56.     }
  57.    
  58.     unsigned short pairCount = 0;
  59.     for(Shoe& e:shoes)
  60.     {
  61.         if(e.paired && e.orientation == 'L')
  62.             pairCount++;
  63.     }
  64.     std::cout << pairCount;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement