Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. #define max(a,b) (((a) > (b)) ? (a) : (b))
  7. #define min(a,b) (((a) < (b)) ? (a) : (b))
  8.  
  9. int n, m;
  10. int arr[500][500];
  11.  
  12. int func(int value, int depth, vector<int>& ppp)
  13. {
  14. int res;
  15.  
  16. for (int i = 0; i < m; i++)
  17. {
  18. if (depth < n - 1)
  19. {
  20. res = func(value ^ arr[depth][i], depth + 1, ppp);
  21. }
  22. else
  23. {
  24. res = value ^ arr[depth][i];
  25. }
  26. if (res > 0)
  27. {
  28. ppp.push_back(i + 1);
  29. return res;
  30. }
  31. }
  32.  
  33. return res;
  34. }
  35.  
  36. int main()
  37. {
  38. cin >> n >> m;
  39. for (int i = 0; i < n; i++)
  40. {
  41. for (int j = 0; j < m; j++)
  42. {
  43. cin >> arr[i][j];
  44. }
  45. }
  46.  
  47. for (int i = 0; i < m; i++)
  48. {
  49. vector<int> ppp;
  50. int l = func(0, 0, ppp);
  51. if (l > 0)
  52. {
  53. cout << "TAK\n";
  54. //ppp.pop ();
  55. for (int i = ppp.size () - 1; i >= 0; i--)
  56. {
  57. cout << ppp [i] << ' ';
  58. }
  59.  
  60. return 0;
  61. }
  62. }
  63.  
  64. cout << "NIE";
  65.  
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement