#include "vision.h"
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<math.h>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;

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

int getMove1d(std::vector<int> v)
{
    ll m = (v.size() - 1) / 2;
    set<pll> s;
    for (ll i = 0; i < v.size(); i++) {
        s.insert({ v[i], i });
    }
    vpll now;
    for (auto i : s) {
        now.push_back(i);
    }
    if (m == 1) {
        if (now[0].first == 1 && now[1].first == 3) {
            return now[1].second;
        }
        return now[0].second;
    }
    else if (m == 2) {
        if (now.back().first == 3) {
            if (v[m + 1] == 2) {
                return m + 1;
            }
            else {
                return m - 1;
            }
        }
        else {
            if (v[m + 1] == 2) {
                return m - 1;
            }
            else {
                return m + 1;
            }
        }
    }
    else {
        if (v[m + 2] == 2) {
            return m + 1;
        }
        else {
            return m - 1;
        }
    }
}

std::vector<std::vector<int>> getVisionPattern2d()
{
    return {{1}};
}

std::pair<int, int> getMove2d(std::vector<std::vector<int>> v)
{
    return {0, 0};
}
