Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- using namespace std;
- map<pair<int, int>, int> used;
- bool check1(pair<int,int> p, int z) {
- int x = p.first, y = p.second;
- if (used[{x + 1, y}] == z and
- used[{x + 2, y}] == z and
- used[{x + 3, y}] == z and
- used[{x + 4, y}] == z) {
- return true;
- }
- return false;
- }
- bool check2(pair<int, int> p, int z) {
- int x = p.first, y = p.second;
- if (used[{x, y + 1}] == z and
- used[{x, y + 2}] == z and
- used[{x, y + 3}] == z and
- used[{x, y + 4}] == z) {
- return true;
- }
- return false;
- }
- bool check3(pair<int, int> p, int z) {
- int x = p.first, y = p.second;
- if (used[{x + 1, y + 1}] == z and
- used[{x + 2, y + 2}] == z and
- used[{x + 3, y + 3}] == z and
- used[{x + 4, y + 4}] == z) {
- return true;
- }
- return false;
- }
- bool check4(pair<int, int> p, int z) {
- int x = p.first, y = p.second;
- if (used[{x - 1, y - 1}] == z and
- used[{x - 2, y - 2}] == z and
- used[{x - 3, y - 3}] == z and
- used[{x - 4, y - 4}] == z) {
- return true;
- }
- return false;
- }
- int main() {
- int n;
- cin >> n;
- vector<pair<int, int>> a, b;
- int flag = 0;
- for (int i = 0; i < n; i++) {
- if (flag > 0) {
- cout << "Inattention";
- return 0;
- }
- int x, y;
- cin >> x >> y;
- if (i % 2 == 0) {
- used[{x, y}] = 1;
- a.push_back({ x,y });
- for (auto el : a) {
- if (check1(el, 1)) {
- flag = 1;
- }
- else if (check2(el, 1)) {
- flag = 1;
- }
- else if (check3(el, 1)) {
- flag = 1;
- }
- else if (check4(el, 1)) {
- flag = 1;
- }
- }
- }
- else {
- used[{x, y}] = 2;
- b.push_back({ x,y });
- for (auto el : b) {
- if (check1(el, 2)) {
- flag = 2;
- }
- else if (check2(el, 2)) {
- flag = 2;
- }
- else if (check3(el, 2)) {
- flag = 2;
- }
- else if (check4(el, 2)) {
- flag = 2;
- }
- }
- }
- }
- if (flag == 1) {
- cout << "First";
- return 0;
- }
- else if (flag == 2) {
- cout << "Second";
- return 0;
- }
- cout << "Draw";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement