// O O O O O O O O O O O O O O O OO O OO O OO O O O TTCH O TTTCH O TTTCH O O O O
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;
#define int long long
#define y1 y11
#define double long double
#define less less228
#define left left228
#define right right228
#define list list228
template<typename T> void uin(T &a, T b) {
if (b < a) a = b;
}
template<typename T> void uax(T &a, T b) {
if (b > a) a = b;
}
random_device rnd;
template<typename T> void shuffle(vector< T > &v) {
for (int i = 1; i < (int)v.size(); ++i) {
swap(v[rnd() % i], v[i]);
}
for (int i = (int)v.size() - 1; i; --i) {
swap(v[rnd() % i], v[i]);
}
}
const int INF = 1e9 + 228;
const int N = 100 * 1000 + 228;
pair<int, int> get(int x1, int y1, int x2, int y2) {
int white = (x2 - x1 + 1) * (y2 - y1 + 1) / 2;
int black = white;
if ( ((x2 - x1 + 1) * (y2 - y1 + 1)) % 2 == 1 ) {
if ((x1 + y1) % 2 == 0) ++white;
else ++black;
}
return {white, black};
}
int n, k;
int x1[N], y1[N], x2[N], y2[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= k; ++i) {
cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
}
int res1 = get(1, 1, n, n).second, res2 = get(1, 1, n, n).first;
for (int i = 1; i <= k; ++i) {
pair<int, int> p = get(x1[i], y1[i], x2[i], y2[i]);
int white = p.first;
int black = p.second;
res1 += white;
res1 -= black;
swap(white, black);
res2 += white;
res2 -= black;
}
cout << min(res1, res2) << '\n';
return 0;
}
// RU_023
/*
2 0
6 8
3 3 3 3
1 2 1 2
3 4 3 4
5 5 5 5
4 3 4 3
4 4 4 4
2 1 2 1
3 6 3 6
4 1
4 1 4 4
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
2292 KB |
Output is correct |
2 |
Correct |
8 ms |
1188 KB |
Output is correct |
3 |
Correct |
21 ms |
2552 KB |
Output is correct |
4 |
Correct |
24 ms |
2680 KB |
Output is correct |
5 |
Correct |
27 ms |
3320 KB |
Output is correct |
6 |
Correct |
17 ms |
2424 KB |
Output is correct |
7 |
Correct |
6 ms |
808 KB |
Output is correct |
8 |
Correct |
19 ms |
2296 KB |
Output is correct |
9 |
Correct |
43 ms |
5248 KB |
Output is correct |
10 |
Correct |
27 ms |
3192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
2292 KB |
Output is correct |
2 |
Correct |
8 ms |
1188 KB |
Output is correct |
3 |
Correct |
21 ms |
2552 KB |
Output is correct |
4 |
Correct |
24 ms |
2680 KB |
Output is correct |
5 |
Correct |
27 ms |
3320 KB |
Output is correct |
6 |
Correct |
17 ms |
2424 KB |
Output is correct |
7 |
Correct |
6 ms |
808 KB |
Output is correct |
8 |
Correct |
19 ms |
2296 KB |
Output is correct |
9 |
Correct |
43 ms |
5248 KB |
Output is correct |
10 |
Correct |
27 ms |
3192 KB |
Output is correct |
11 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |