Submission #48842

#TimeUsernameProblemLanguageResultExecution timeMemory
48842mrtsima22Chessboard (IZhO18_chessboard)C++17
70 / 100
280 ms36896 KiB
#include <bits/stdc++.h> using namespace std; int a[100000], b[100000], x2[100000], y2[100000]; int main() { int n, k; long long ansT, ans = 10000000000LL; cin>>n>>k; for(int i = 0; i < k; ++i) { cin>>a[i]>>b[i]>>x2[i]>>y2[i]; a[i]--;b[i]--; x2[i]--;y2[i]--; } for(int j = 1; j < n; ++j) if(n % j == 0) { ansT = 0; for(int i = 0; i < k; ++i) if((a[i]/j + b[i]/j) % 2 == 0) ++ansT; ansT = ansT * 2 - k; if(ansT + (long long)n * n / j / j / 2 * j * j < ans) ans = ansT + (long long)n * n / j / j / 2 * j * j; ansT = -ansT; if(ansT + ((long long)n * n / j / j + 1) / 2 * j * j < ans) ans = ansT + ((long long)n * n / j / j + 1) / 2 * j * j; } cout<<ans<<endl; 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...