#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; int dx[4][2] = {{2, 2}, {-2, -2}, {1, -1}, {1, -1}}; int dy[4][2] = {{1, -1}, {1, -1}, {2, 2}, {-2, -2}}; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector

xy(n); vector

cand; map p2i; rep(i, n) { auto& [x, y] = xy[i]; cin >> x >> y; p2i[{x, y}] = i; rep(k, 4) rep(z, 2) cand.emplace_back(x + dx[k][z], y + dy[k][z]); } constexpr int INF = 1001001001; VI dp(1 << n, INF); dp[0] = 0; sort(all(cand)); cand.erase(unique(all(cand)), cand.end()); for (auto [p, q] : cand) if (!p2i.contains(P(p, q))) { VI ndp = dp; rep(k, 4) { int bit = 0; rep(z, 2) { auto it = p2i.find(P(p + dx[k][z], q + dy[k][z])); if (it != p2i.end()) bit |= 1 << it->second; } if (!bit) continue; rep(s, 1 << n) if (int val = dp[s]; val != INF) { chmin(ndp[s | bit], dp[s] + 1); } } swap(dp, ndp); } int ans = dp.back(); if (ans == INF) ans = -1; cout << ans << '\n'; }