/** @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;
int cnt[2];
cnt[0] = cnt[1] = 1;
for(int i = 0; i < k; i++){
cin >> x1 >> y1 >> x2 >> y2;
cnt[(x1 + y1) % 2]++;
}
cout << min((n * 1ll * n) / 2 - cnt[0] + cnt[1], (n * 1ll * n) / 2 - cnt[1] + cnt[0]);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
1772 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
1772 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Incorrect |
24 ms |
1772 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |