Submission #47264

#TimeUsernameProblemLanguageResultExecution timeMemory
47264jun6873Chessboard (IZhO18_chessboard)C++11
70 / 100
382 ms61344 KiB
#include <iostream> #include <algorithm> using namespace std; typedef long long lint; const int maxn = 100004; int n, k, x1[maxn], y1[maxn], x2[maxn], y2[maxn]; lint s; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (int i=0; i<k; i++) { cin >> x1[i] >> y1[i] >> x2[i] >> y2[i]; x1[i]--; y1[i]--; x2[i]--; y2[i]--; s += (x2[i] - x1[i] + 1) * (lint)(y2[i] - y1[i] + 1); } lint ans = 1ll << 50; for (lint i=1; i<n; i++) if (n%i == 0) { lint t = 0, a, b; a = ((n/i) * (n/i) + 1) / 2 * i * i; b = ((n/i) * (n/i)) / 2 * i * i; for (int j=0; j<k; j++) { if ((x1[j]/i) % 2 == (y1[j]/i) % 2) t++; } ans = min(ans, (a - t) + (s-t)); ans = min(ans, (b - (s-t)) + t); } cout << ans << '\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...