Submission #77048

# Submission time Handle Problem Language Result Execution time Memory
77048 2018-09-20T11:48:21 Z antimirage Chessboard (IZhO18_chessboard) C++17
8 / 100
49 ms 11288 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, k, x[2][N], y[2][N];

long long ans = 1e18;

int main()
{
    cin >> n >> k;

    for (int i = 1; i <= k; i++)
    {
        scanf("%d%d", &x[0][i], &y[0][i]), x[0][i]--, y[0][i]--;
        scanf("%d%d", &x[1][i], &y[1][i]), x[1][i]--, y[1][i]--;
    }
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i != 0) continue;

        long long res = 0;

        for (int j = 1; j <= k; j++)
        {
            if ((x[0][j] / i + y[0][j] / i) & 1)
                res++;
        }
//        cout << i << " --> " << min( res + (n * 1ll * n + 1) / 2 - (k - res), (k - res) + (n * 1ll * n) / 2  - res) << endl;
        ans = min(ans, min( res + (n * 1ll * n + 1) / 2 - (k - res), (k - res) + (n * 1ll * n) / 2  - res) );
    }
    cout << ans << endl;
}
/**
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
**/

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:17:53: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x[0][i], &y[0][i]), x[0][i]--, y[0][i]--;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
chessboard.cpp:18:53: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &x[1][i], &y[1][i]), x[1][i]--, y[1][i]--;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2844 KB Output is correct
2 Correct 11 ms 2844 KB Output is correct
3 Correct 25 ms 3980 KB Output is correct
4 Correct 23 ms 4808 KB Output is correct
5 Correct 31 ms 6244 KB Output is correct
6 Correct 20 ms 6888 KB Output is correct
7 Correct 6 ms 6888 KB Output is correct
8 Correct 19 ms 7748 KB Output is correct
9 Correct 49 ms 10908 KB Output is correct
10 Correct 26 ms 11288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 11288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 11288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2844 KB Output is correct
2 Correct 11 ms 2844 KB Output is correct
3 Correct 25 ms 3980 KB Output is correct
4 Correct 23 ms 4808 KB Output is correct
5 Correct 31 ms 6244 KB Output is correct
6 Correct 20 ms 6888 KB Output is correct
7 Correct 6 ms 6888 KB Output is correct
8 Correct 19 ms 7748 KB Output is correct
9 Correct 49 ms 10908 KB Output is correct
10 Correct 26 ms 11288 KB Output is correct
11 Incorrect 2 ms 11288 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -