#include "vision.h"
#include <cassert>
#include <iostream>
using namespace std;

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

int getMove1d(std::vector<int> v) {
    int _n = v.size();
    int mid = _n / 2;
    if (v[mid] == 1) {
        if (v[_n / 2 + 1] == 1 || v[_n / 2 + 1] == 2) {
            return _n / 2 + 1;
        }
        return _n / 2 - 1;
    }
    // cerr << v[_n / 2] << endl;
    if ((v[_n / 2] + 1) % 3 == v[_n / 2 + 1] % 3) {
        // cerr << v[_n / 2 + 1] << endl;
        return _n / 2 + 1;
    }
    // cerr << v[_n / 2 - 1] << endl;
    return _n / 2 - 1;
    if (v[mid] == 1) {
        int l = v[mid - 1], r = v[mid + 1];
        int li = mid - 1, ri = mid + 1;
        if (l == 3 && r == 1) {
            return ri;
        }
        if (l == 1 && r == 2) {
            return ri;
        }
        // if (l == 2 && r == 2) {
        //     return ri;
        // }
        if (l == 2 && r == 3) {
            return ri;
        }
        return li;
    }
    if (v[mid] == 2) {
        int li = mid - 2, ri = mid + 2;
        int l = v[li], r = v[ri];
        if (l == 1 && r == 3) {
            return ri;
        }
        if (l == 1 && r == 1)
            return ri;
        return li;
    }
    if (v[mid] == 3) {
        int li = mid - 2, ri = mid + 2;
        int l = v[li], r = v[ri];
        if (r == 1) {
            return ri;
        }
        return li;
    }
    assert(0);
}

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

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