Advertisement
cyberjab

Untitled

Apr 14th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. map<pair<int, int>, int> used;
  8.  
  9. bool check1(pair<int,int> p, int z) {
  10. int x = p.first, y = p.second;
  11. if (used[{x + 1, y}] == z and
  12. used[{x + 2, y}] == z and
  13. used[{x + 3, y}] == z and
  14. used[{x + 4, y}] == z) {
  15. return true;
  16. }
  17. return false;
  18. }
  19.  
  20. bool check2(pair<int, int> p, int z) {
  21. int x = p.first, y = p.second;
  22. if (used[{x, y + 1}] == z and
  23. used[{x, y + 2}] == z and
  24. used[{x, y + 3}] == z and
  25. used[{x, y + 4}] == z) {
  26. return true;
  27. }
  28. return false;
  29. }
  30.  
  31. bool check3(pair<int, int> p, int z) {
  32. int x = p.first, y = p.second;
  33. if (used[{x + 1, y + 1}] == z and
  34. used[{x + 2, y + 2}] == z and
  35. used[{x + 3, y + 3}] == z and
  36. used[{x + 4, y + 4}] == z) {
  37. return true;
  38. }
  39. return false;
  40. }
  41.  
  42. bool check4(pair<int, int> p, int z) {
  43. int x = p.first, y = p.second;
  44. if (used[{x - 1, y - 1}] == z and
  45. used[{x - 2, y - 2}] == z and
  46. used[{x - 3, y - 3}] == z and
  47. used[{x - 4, y - 4}] == z) {
  48. return true;
  49. }
  50. return false;
  51. }
  52.  
  53. int main() {
  54. int n;
  55. cin >> n;
  56. vector<pair<int, int>> a, b;
  57. int flag = 0;
  58. for (int i = 0; i < n; i++) {
  59. if (flag > 0) {
  60. cout << "Inattention";
  61. return 0;
  62. }
  63. int x, y;
  64. cin >> x >> y;
  65. if (i % 2 == 0) {
  66. used[{x, y}] = 1;
  67. a.push_back({ x,y });
  68. for (auto el : a) {
  69. if (check1(el, 1)) {
  70. flag = 1;
  71. }
  72. else if (check2(el, 1)) {
  73. flag = 1;
  74. }
  75. else if (check3(el, 1)) {
  76. flag = 1;
  77. }
  78. else if (check4(el, 1)) {
  79. flag = 1;
  80. }
  81. }
  82. }
  83. else {
  84. used[{x, y}] = 2;
  85. b.push_back({ x,y });
  86. for (auto el : b) {
  87. if (check1(el, 2)) {
  88. flag = 2;
  89. }
  90. else if (check2(el, 2)) {
  91. flag = 2;
  92. }
  93. else if (check3(el, 2)) {
  94. flag = 2;
  95. }
  96. else if (check4(el, 2)) {
  97. flag = 2;
  98. }
  99. }
  100. }
  101. }
  102. if (flag == 1) {
  103. cout << "First";
  104. return 0;
  105. }
  106. else if (flag == 2) {
  107. cout << "Second";
  108. return 0;
  109. }
  110. cout << "Draw";
  111. return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement