Submission #191051

# Submission time Handle Problem Language Result Execution time Memory
191051 2020-01-14T11:09:47 Z godwind Chessboard (IZhO18_chessboard) C++14
0 / 100
30 ms 3816 KB
// 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(1, 1, n, n);
        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 1 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 3816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 3816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -