#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long

vector<int> getVisionPattern1d() {
    return {3, 1, 2};
}

int getMove1d(vector<int> v) {
    int n = v.size() / 2;
    if(n == 1) {
        if(v[2] == 2) return 2;
        else return 0;
    } if(n == 2) {
        if(v[4] == 1) return 4;
        else return 0;
    } if(n == 3) {
        if(v[5] == 2) return 6;
        else return 0;
    }
    return n;
}

vector<vector<int>> getVisionPattern2d() {
    return {
        {2, 1, 3},
        {1, 1, 1},
        {1, 1, 4},
    };
}

pair<int, int> getMove2d(vector<vector<int>> v) {
    int n = v.size() / 2;
    if(n == 1) {
        if(v[0][0] == 4) return {0, 0};
        if(v[0][1] == 4) return {0, 1};
        if(v[0][2] == 4) return {0, 2};
        if(v[1][0] == 4) return {1, 0};
        if(v[1][2] == 4) return {1, 2};
        if(v[2][0] == 4) return {2, 0};
        if(v[2][1] == 4) return {2, 1};
        if(v[2][2] == 4) return {2, 2};
    } if(n == 2) {
        if(v[4][4] == 4) return {4, 4};
        if(v[0][0] == 4) return {0, 0};
        if(v[0][4] == 4) return {0, 4};
        if(v[4][0] == 4) return {4, 0};
    } if(n == 3) return {1, 1};
    if(n == 4) {
        if(v[8][8] == 2) return {8, 8};
        if(v[0][0] == 2) return {0, 0};
        if(v[0][8] == 2) return {0, 8};
        if(v[8][0] == 2) return {8, 0};
    }

    return {n, n};
}
