Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10. #define MAX 1000000001
  11. using namespace std;
  12.  
  13.  
  14. int main()
  15. {
  16.  
  17. int tab[MAX] = {};
  18.  
  19. int n;
  20. std::cin >> n;
  21. for(int i = 0; i < n; ++i) {
  22. int first, second;
  23. std::cin >> first;
  24. std::cin >> second;
  25. tab[first]++;
  26. tab[second]++;
  27. }
  28.  
  29. int numbers[2];
  30. int odd_counter = 0;
  31.  
  32. for(int i = 0; i < MAX; ++i) {
  33. if(tab[i] > 0) {
  34. if(tab[i] % 2 == 1) {
  35. numbers[odd_counter] = i;
  36. odd_counter++;
  37. }
  38. }
  39. }
  40.  
  41. if(odd_counter == 2) {
  42. std::cout << numbers[0] << " " << numbers[1];
  43. }
  44.  
  45. else {
  46. std::cout << "NIE" << std::endl;
  47. }
  48.  
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement