fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <cstdint>
  5.  
  6. typedef std::vector<std::uint64_t> LType;
  7. typedef std::map<std::uint64_t, std::uint64_t> MType;
  8.  
  9. bool MakeHoge(LType& A, LType& B){
  10. MType M;
  11. std::uint64_t N = 0;
  12. for (auto& o : A){
  13. M[o]++;
  14. }
  15. for (auto& o : B){
  16. if (M[o] != 0){
  17. N++;
  18. M[o]--;
  19. }
  20. }
  21. return N == 2;
  22. }
  23.  
  24. bool Show(LType& A, LType& B, bool R){
  25. std::cout <<'[';
  26. for (auto& o : A){
  27. std::cout << o << ' ';
  28. }
  29. std::cout <<']';
  30. std::cout <<'[';
  31. for (auto& o : B){
  32. std::cout << o << ' ';
  33. }
  34. std::cout <<']'<<' '<<"->"<<' ';
  35.  
  36. std::cout << (R? "真" : "偽") << std::endl;
  37. return true;
  38. }
  39.  
  40.  
  41.  
  42. int main(){
  43. LType A, B;
  44. bool R;
  45. A = { 1, 2, 3 };
  46. B = { 1, 2, 3 };
  47. R = MakeHoge(A, B);
  48. Show(A, B, R);
  49.  
  50. A = { 1, 2, 3 };
  51. B = { 5, 6, 7 };
  52. R = MakeHoge(A, B);
  53. Show(A, B, R);
  54.  
  55. A = { 1, 1, 1 };
  56. B = { 1, 1, 2 };
  57. R = MakeHoge(A, B);
  58. Show(A, B, R);
  59.  
  60. A = { 1, 1, 2, };
  61. B = { 2, 2, 1 };
  62. R = MakeHoge(A, B);
  63.  
  64. Show(A, B, R);
  65. A = { 9, 8, 9 };
  66. B = { 8, 6, 4 };
  67. R = MakeHoge(A, B);
  68. Show(A, B, R);
  69.  
  70. A = { 9, 7, 2 };
  71. B = { 2, 2, 9 };
  72. R = MakeHoge(A, B);
  73. Show(A, B, R);
  74. return 0;
  75. }
  76. /** /
  77. [1, 2, 3], [1, 2, 3]->偽
  78. [1, 2, 3], [5, 6, 7]->偽
  79. [1, 1, 1], [1, 1, 2]->真
  80. [1, 1, 2], [2, 2, 1]->真
  81. [9, 8, 9], [8, 6, 4]->偽
  82. [9, 7, 2], [2, 2, 9]->真
  83. /**/
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
[1 2 3 ][1 2 3 ] -> 偽
[1 2 3 ][5 6 7 ] -> 偽
[1 1 1 ][1 1 2 ] -> 真
[1 1 2 ][2 2 1 ] -> 真
[9 8 9 ][8 6 4 ] -> 偽
[9 7 2 ][2 2 9 ] -> 真