Submission #994750

# Submission time Handle Problem Language Result Execution time Memory
994750 2024-06-08T04:52:48 Z emptypringlescan Portal (BOI24_portal) C++14
Compilation error
0 ms 0 KB
#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;
	}
}

Compilation message

Main.cpp: In function 'int32_t main()':
Main.cpp:29:13: error: 'gcd' was not declared in this scope
   29 |     else gx=gcd(gx,dx);
      |             ^~~
Main.cpp:33:13: error: 'gcd' was not declared in this scope
   33 |     else gy=gcd(gy,dy);
      |             ^~~