#include <bits/stdc++.h>
using namespace std;
const int MAXCOORD = 205;
bool vis[2*MAXCOORD][2*MAXCOORD];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
int x[N+1], y[N+1];
for (int i = 1; i <= N; i++) cin >> x[i] >> y[i];
for (int i = 1; i <= N; i++) x[i] += MAXCOORD, y[i] += MAXCOORD;
bool find_diff = false;
for (int i = 2; i <= N; i++) {
for (int j = 2; j <= i; j++) {
long long t1 = (x[i]-x[1])*(y[j]-y[1]);
long long t2 = (x[j]-x[1])*(y[i]-y[1]);
find_diff |= (t1 != t2);
}
}
if (!find_diff) {
cout << -1;
return 0;
}
int ans = 0;
for (int i = 0; i < 2*MAXCOORD; i++) {
for (int j = 0; j < 2*MAXCOORD; j++) {
if (vis[i][j]) continue;
ans++;
queue<pair<int, int>> bfs;
bfs.emplace(i, j);
while (!bfs.empty()) {
auto [a, b] = bfs.front();
bfs.pop();
if (vis[a][b]) continue;
vis[a][b] = true;
for (int i = 2; i <= N; i++) {
int na = a + x[i]-x[1], nb = b + y[i]-y[1];
if (0 <= na && na < 2*MAXCOORD && 0 <= nb && nb < 2*MAXCOORD) {
bfs.emplace(na, nb);
}
}
for (int i = 2; i <= N; i++) {
int na = a + x[1]-x[i], nb = b + y[1]-y[i];
if (0 <= na && na < 2*MAXCOORD && 0 <= nb && nb < 2*MAXCOORD) {
bfs.emplace(na, nb);
}
}
}
}
}
cout << ans;
return 0;
}
/*
3
1 1
1 3
3 2
5
0 0
1 0
-1 0
0 1
0 -1
1
1 -1
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |