This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/** @BY_KUTBILIM **/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
const int inf = (int)1e9+7;
int main(){
ios_base::sync_with_stdio(false);
cin.tie();
int n, k;
cin >> n >> k;
if(k == 0){
int ans = n * n;
for(int i = 1; i <= n / 2; i++){
if(n % i != 0)continue;
int cur = 0;
for(int I = 0; I < n; I += i){
for(int J = ((I / i) % 2 ? i : 0); J < n; J += i*2){
cur += (i * i);
}
}
ans = min({ans, cur, n * n - cur});
}
cout << ans;
} else{
int x1, y1, x2, y2;
ll cnt[2];
cnt[0] = cnt[1] = 0;
for(int i = 0; i < k; i++){
cin >> x1 >> y1 >> x2 >> y2;
cnt[(x1 + y1) % 2] += 1ll;
}
if(n == 2)
cout << min(2 - cnt[0] + cnt[1], 2 - cnt[1] + cnt[0]);
else
cout << min((n * 1ll * n) / 2ll + 1 - cnt[0] + cnt[1], (n * 1ll * n) / 2ll - cnt[1] + cnt[0]);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |