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;
int grid[1005][1005];
vector<pair<int,int> > step;
void dfs(int x, int y){
if(x<0||x>1000||y<0||y>1000) return;
if(grid[x][y]) return;
grid[x][y]=1;
for(pair<int,int> i:step){
if(x+i.first>=0&&x+i.first<=1000&&y+i.second>=0&&y+i.second<=1000){
if(grid[x+i.first][y+i.second]==0) dfs(x+i.first,y+i.second);
}
}
}
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
pair<int,int> arr[n];
for(int i=0; i<n; i++) cin >> arr[i].first >> arr[i].second;
if(n==2||n==1) cout << -1;
else{
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(i==j) continue;
step.push_back({arr[i].first-arr[j].first,arr[i].second-arr[j].second});
}
}
int cnt=0;
for(int i=0; i<1000; i++){
for(int j=0; j<1000; j++){
if(grid[i][j]) continue;
cnt++;
dfs(i,j);
}
}
cout << (cnt>=1000000?-1:cnt);
}
}
# | 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... |