Submission #994743

#TimeUsernameProblemLanguageResultExecution timeMemory
994743emptypringlescanPortal (BOI24_portal)C++14
1 / 100
2100 ms1048576 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...