This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, ans = 0;
cin >> n;
int x[n], y[n];
for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
if(n == 1) {
cout << -1;
return 0;
}
int X = 401, Y = 401;
int grid[X][Y];
memset(grid, -1, sizeof(grid));
for(int i = 0; i < X; i++) {
for(int j = 0; j < Y; j++) {
if(grid[i][j] != -1) continue;
queue<pair<int, int>> q;
q.push({i,j});
grid[i][j] = ans;
while(!q.empty()) {
pair<int, int> c = q.front();
q.pop();
for(int r = 0; r < n; r++) {
for(int s = 0; s < n; s++) {
int nx = c.first+x[r]-x[s];
int ny = c.second+y[r]-y[s];
if(nx < 0 || nx >= X || ny < 0 || ny >= Y) continue;
if(grid[nx][ny] != -1) continue;
grid[nx][ny] = ans;
q.push({nx, ny});
}
}
}
ans++;
}
}
cout << ans;
}
# | 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... |