Submission #994751

#TimeUsernameProblemLanguageResultExecution timeMemory
994751emptypringlescanPortal (BOI24_portal)C++17
11 / 100
17 ms1248 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{ int gx=-1,gy=-1; for(int i=1; i<n; i++){ int dx=abs(arr[i].first-arr[0].first),dy=abs(arr[i].second-arr[0].second); if(dx){ if(gx==-1) gx=dx; else gx=gcd(gx,dx); } if(dy){ if(gy==-1) gy=dy; else gy=gcd(gy,dy); } } if(gx==-1||gy==-1) cout << -1; else cout << gx*gy; } }
#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...