제출 #1329642

#제출 시각아이디문제언어결과실행 시간메모리
1329642ErJPortal (BOI24_portal)C++20
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define pp pair<ll, ll>
#define vp vector<pp>
#define inf 1000000000
#define mod 1000000007

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    vp point(n);
    for(int i = 0; i < n; i++){
        cin >> point[i].first >> point[i].second;
    }
    sort(point.begin(), point.end());
    ll row = 0;
    for(int i = 1; i < n; i++){
        if(point[i].first == point[i - 1].first){
            ll val = point[i].second - point[i - 1].second;
            if(row == 0) row = val;
            row = gcd(row, val);
        }
    }
    for(int i = 0; i < n; i++) swap(point[i].first, point[i].second);
    sort(point.begin(), point.end());
    ll col = 0;
    for(int i = 1; i < n; i++){
        if(point[i].first == point[i - 1].first){
            ll val = point[i].second - point[i - 1].second;
            if(col == 0) col = val;
            col = gcd(col, val);
        }
    }

    cout << row * col << '\n';
}
#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...