/** @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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
364 KB |
Output is correct |
2 |
Correct |
8 ms |
364 KB |
Output is correct |
3 |
Correct |
15 ms |
364 KB |
Output is correct |
4 |
Correct |
16 ms |
364 KB |
Output is correct |
5 |
Correct |
20 ms |
364 KB |
Output is correct |
6 |
Correct |
13 ms |
364 KB |
Output is correct |
7 |
Correct |
3 ms |
364 KB |
Output is correct |
8 |
Correct |
17 ms |
364 KB |
Output is correct |
9 |
Correct |
33 ms |
364 KB |
Output is correct |
10 |
Correct |
20 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
30 ms |
364 KB |
Output is correct |
2 |
Correct |
8 ms |
364 KB |
Output is correct |
3 |
Correct |
15 ms |
364 KB |
Output is correct |
4 |
Correct |
16 ms |
364 KB |
Output is correct |
5 |
Correct |
20 ms |
364 KB |
Output is correct |
6 |
Correct |
13 ms |
364 KB |
Output is correct |
7 |
Correct |
3 ms |
364 KB |
Output is correct |
8 |
Correct |
17 ms |
364 KB |
Output is correct |
9 |
Correct |
33 ms |
364 KB |
Output is correct |
10 |
Correct |
20 ms |
364 KB |
Output is correct |
11 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
30 ms |
364 KB |
Output is correct |
10 |
Correct |
8 ms |
364 KB |
Output is correct |
11 |
Correct |
15 ms |
364 KB |
Output is correct |
12 |
Correct |
16 ms |
364 KB |
Output is correct |
13 |
Correct |
20 ms |
364 KB |
Output is correct |
14 |
Correct |
13 ms |
364 KB |
Output is correct |
15 |
Correct |
3 ms |
364 KB |
Output is correct |
16 |
Correct |
17 ms |
364 KB |
Output is correct |
17 |
Correct |
33 ms |
364 KB |
Output is correct |
18 |
Correct |
20 ms |
364 KB |
Output is correct |
19 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |