Submission #1124247

#TimeUsernameProblemLanguageResultExecution timeMemory
1124247mychecksedadPortal (BOI24_portal)C++17
0 / 100
5 ms328 KiB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30, S = 300;


ll n;
array<ll, 2> a[N];
void solve(){
  cin >> n;
  ll gx = 0;
  for(int i = 1; i <= n; ++i){
    cin >> a[i][0] >> a[i][1];
    if(i>1) gx=gcd(gx,abs(a[i][0]-a[i-1][0]));
  }
  ll ans = gx;
  sort(a+1, a+1+n);
  for(ll h = 2; h <= 200; ++h){
    bool ok = 0;
    int tot = 0;
    for(ll s = 0; s <= 200; ++s){
      bool kk = 1;
      tot = 0;
      for(int i = 2; i <= n; ++i){
        tot += a[i][0] - a[i - 1][0];
        // if(h == 2 && s == 1){

        // cout << a[i][0] << ' ' << a[i - 1][0] << ' ';
        //   cout << tot << ' ' << tot/gx*s << '\n';  
        // }
        if((tot / gx * s + 200*h) % h != (a[i][1] - a[1][1] + h * 200) % h) kk = 0;
      }
      if(kk){
        ok = 1;
        break;
      }
    }
    if(ok) ans = max(ans, h*gx);
  }
  cout << ans;

  // vector<pair<int, int>> p;
  // for(int i = 1; i <= n; ++i){
  //   for(int j = i + 1; j <= n; ++j){
  //     p.pb({a[i][0] - a[j][0], a[i][1] - a[j][1]});
  //     p.pb({a[j][0] - a[i][0], a[j][1] - a[i][1]});
  //   }
  // }
  // for(auto x: p) cout << x.ff << ' ' << x.ss << '\n';
  // vector<vector<int>> col(100, vi(100, -1));
  // int c = 0;
  // for(int i = 0; i < 100; ++i){
  //   for(int j = 0; j < 100; ++j){
  //     if(col[i][j] == -1){
  //       for(auto x: p){
  //         int nx = x.ff + i, ny = x.ss + j;
  //         if(nx >= 0 && ny >= 0 && nx < 100 && ny < 100){
  //           if(col[nx][ny] != -1) col[i][j] = col[nx][ny];
  //         }
  //       }
  //       if(col[i][j] == -1)
  //       col[i][j] = c++;
  //     }
  //     for(auto x: p){
  //       int nx = x.ff + i, ny = x.ss + j;
  //       if(nx >= 0 && ny >= 0 && nx < 100 && ny < 100){
  //         col[nx][ny] = col[i][j];
  //       }
  //     }
  //   }
  // }
  // for(int i = 0; i < 15; ++i){
  //   for(int j = 0; j < 15; ++j) cout << col[i][j] << ' ';
  //   en;
  // }

}


int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tt = 1, aa;
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  while(tt--){
    solve();
    en;
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  return 0;
} 
#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...