Submission #907412

#TimeUsernameProblemLanguageResultExecution timeMemory
907412daoquanglinh2007Chessboard (IZhO18_chessboard)C++17
0 / 100
16 ms1880 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int NM = 1e5, inf = 1e18; int N, K, x[NM+5], y[NM+5], ans = +inf; int num[2]; void solve(int t){ num[0] = num[1] = 0; for (int i = 1; i <= K; i++){ int blx = x[i]/t+(x[i]%t > 0), bly = y[i]/t+(y[i]%t > 0); num[(blx+bly)%2]++; } int targ = t*t*(N*N/(t*t)/2); cout << N << ' ' << t << ' ' << targ << endl; ans = min(ans, abs(targ-num[0])+num[1]); ans = min(ans, abs(targ-num[1])+num[0]); ans = min(ans, abs(N*N-targ-num[0])+num[1]); ans = min(ans, abs(N*N-targ-num[1])+num[0]); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K; for (int i = 1; i <= K; i++){ cin >> x[i] >> y[i] >> x[i] >> y[i]; } for (int i = 1; i*i <= N; i++) if (N%i == 0){ solve(i); if (i > 1) solve(N/i); } cout << ans; 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...