#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll gcd(ll a, ll b){return __gcd(abs(a), abs(b));}
ll lcm(ll a, ll b){return abs(a) / gcd(a, b) * abs(b);}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ull mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
double rngesus_d(double l, double r){
double cur = rngesus(0, MASK(60) - 1);
cur /= MASK(60) - 1;
return l + cur * (r - l);
}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){
for(auto item: container) out << item << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
const int N = 300;
bool grid[N*2+1][N*2+1];
pair<ll, ll> vt[N];
ll solve(){
int n; cin >> n;
vector<pair<ll, ll>> portal(n);
for(int i = 0; i < n; ++i) cin >> portal[i].first >> portal[i].second;
if (n <= 2){
return -1;
}
sort(ALL(portal));
for(int i = 0; i + 1 < n; ++i){
vt[i] = make_pair(portal.back().first - portal[i].first, portal.back().second - portal[i].second);
}
vector<pair<int, int>> st; st.reserve(N * N);
st.push_back(make_pair(N, N));
grid[N][N] = 1;
while(st.size()){
int x, y; tie(x, y) = st.back(); st.pop_back();
for(int i = 0; i < n-1; ++i){
pair<ll, ll> dih = vt[i];
for(int it = 0; it <= 1; ++it){
int u = x + dih.first, v = y + dih.second;
if (min(u, v) < 0 || max(u, v) > N*2) continue;
if (grid[u][v] == 0) st.push_back(make_pair(u, v));
grid[u][v] = 1;
dih = make_pair(-dih.first, -dih.second);
}
}
}
ll nearest_x = 0, nearest_y = 0;
for(int i = N+1; i <= N*2; ++i) if (grid[i][N]){
nearest_x = i - N;
break;
}
for(int j = N+1; j <= N*2; ++j) for(int i = 0; i <= N*2; ++i) if (grid[i][j]){
if (nearest_y == 0)
nearest_y = j - N;
break;
}
if (nearest_x * nearest_y == 0) return -1;
ll ans = nearest_x * nearest_y;
return ans;
}
int main(void){
ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
cout << solve() << "\n";
return 0;
}
# | 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... |