Submission #779381

# Submission time Handle Problem Language Result Execution time Memory
779381 2023-07-11T11:22:58 Z vjudge1 Chessboard (IZhO18_chessboard) C++17
39 / 100
114 ms 5840 KB
#include <iostream>
#define MAX 1000
using namespace std;
///ifstream cin ("c.in");
///ofstream cout ("c.out");
int a[MAX + 10][MAX + 10];
void speedy()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    speedy();
    int n, k;
    cin >> n >> k;
    for (int kk = 1; kk <= k; kk++)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        for (int i = x1; i <= x2; i++)
            for (int j = y1; j <= y2; j++)
                a[i][j] = 1;
    }
    int ans = n * n + 10;
    for (int side = 1; side < n; side++)
        if (n % side == 0)
        {
            int change, cnt = n / side;
            ///make (1, 1, side, side) white
            change = 0;
            for (int auxi = 1; auxi <= cnt; auxi++)
                for (int auxj = 1; auxj <= cnt; auxj++)
                    for (int i = side * (auxi - 1) + 1; i <= side * auxi; i++)
                        for (int j = side * (auxj - 1) + 1; j <= side * auxj; j++)
                        {
                            if (auxi % 2 == 1 && auxj % 2 == 1)
                                if (a[i][j] == 1)
                                    change++;
                            if (auxi % 2 == 1 && auxj % 2 == 0)
                                if (a[i][j] == 0)
                                    change++;
                            if (auxi % 2 == 0 && auxj % 2 == 1)
                                if (a[i][j] == 0)
                                    change++;
                            if (auxi % 2 == 0 && auxj % 2 == 0)
                                if (a[i][j] == 1)
                                    change++;
                        }
            ans = min(ans, change);
            ///make (1, 1, side, side) black
            change = 0;
            for (int auxi = 1; auxi <= cnt; auxi++)
                for (int auxj = 1; auxj <= cnt; auxj++)
                    for (int i = side * (auxi - 1) + 1; i <= side * auxi; i++)
                        for (int j = side * (auxj - 1) + 1; j <= side * auxj; j++)
                        {
                            if (auxi % 2 == 1 && auxj % 2 == 1)
                                if (a[i][j] == 0)
                                    change++;
                            if (auxi % 2 == 1 && auxj % 2 == 0)
                                if (a[i][j] == 1)
                                    change++;
                            if (auxi % 2 == 0 && auxj % 2 == 1)
                                if (a[i][j] == 1)
                                    change++;
                            if (auxi % 2 == 0 && auxj % 2 == 0)
                                if (a[i][j] == 0)
                                    change++;
                        }
            ans = min(ans, change);
        }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 584 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 19 ms 4428 KB Output is correct
17 Correct 24 ms 5528 KB Output is correct
18 Correct 35 ms 5840 KB Output is correct
19 Correct 110 ms 5528 KB Output is correct
20 Correct 114 ms 5704 KB Output is correct
21 Correct 24 ms 5520 KB Output is correct
22 Correct 46 ms 1748 KB Output is correct
23 Correct 34 ms 4828 KB Output is correct
24 Correct 33 ms 5644 KB Output is correct
25 Correct 25 ms 4180 KB Output is correct
26 Correct 26 ms 4948 KB Output is correct
27 Correct 34 ms 5224 KB Output is correct
28 Correct 34 ms 5624 KB Output is correct
29 Correct 18 ms 4580 KB Output is correct
30 Correct 18 ms 4004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Runtime error 1 ms 468 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -