Submission #1114631

#TimeUsernameProblemLanguageResultExecution timeMemory
1114631adiyerChessboard (IZhO18_chessboard)C++17
70 / 100
151 ms5960 KiB
#include <bits/stdc++.h> #define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0); #define all(x) (x.begin(), x.end()) #define pb push_back #define int long long typedef long long ll; using namespace std; const int N = 1e5 + 11; const int mod = 1e9 + 7; const ll inf = 1e18 + 11; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); ll n, m; ll ax[N], bx[N], ay[N], by[N]; vector < ll > d; bool check(ll x, ll y, ll sz){ ll a = x % (sz * 2); ll b = y % (sz * 2); a = bool(1 <= a && a <= sz); b = bool(1 <= b && b <= sz); // cout << x << ' ' << y << ' ' << a << ' ' << b << ' ' << sz << ' ' << ((a + b) & 1) << '\n'; return ((a + b) & 1); } void solve(){ cin >> n >> m; for(int i = 1; i <= m; i++) cin >> ax[i] >> ay[i] >> bx[i] >> by[i]; for(int i = 1; i < n; i++){ if(n % i == 0){ d.pb(i); } } ll mn = inf; for(int sz : d){ ll cur1 = ((n / sz) * (n / sz) / 2) * (sz * sz); ll cur2 = ((n / sz) * (n / sz) - ((n / sz) * (n / sz) / 2)) * (sz * sz); cur1 -= m, cur2 -= m; for(int i = 1; i <= m; i++){ if(!check(ax[i], ay[i], sz)) cur1 += 2; else cur2 += 2; } // cout << sz << ' ' << cur1 << ' ' << cur2 << '\n'; mn = min(mn, min(cur1, cur2)); } cout << mn; } const bool Cases = 0; signed main(){ adiyer(); int CS = 1; if(Cases) cin >> CS; while(CS--) solve(); }
#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...