Submission #378836

# Submission time Handle Problem Language Result Execution time Memory
378836 2021-03-17T05:50:26 Z LittleCube Chessboard (IZhO18_chessboard) C++14
70 / 100
337 ms 3564 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

/*************************************
 * 
 *  Without Subtask 4 : 70 points
 *  
 */
struct point
{
    int x1, y1, x2, y2;
};

signed main()
{

    int n, m, k, ans = 100000000000;
    cin >> n >> k;
    vector<point> v(k);
    vector<int> fac;
    for (int i = 0; i < k; i++)
        cin >> v[i].x1 >> v[i].y1 >> v[i].x2 >> v[i].y2;

    for (int i = 1; i <= sqrt(n); i++)
    {
        if(n % i == 0)
        {
            fac.emplace_back(i);
            if (i * i != n && i != 1)
                fac.emplace_back(n / i);
        }
    }
    for (int i : fac)
        if (n % i == 0)
        {
            int l = 0, r = 0;
            for (auto j : v)
                if (((j.x1 + i - 1) / i + (j.y1 + i - 1) / i) % 2)
                    r++;
                else
                    l++;
            //cout << i << " " << min({(n * n - i * i + 1) / 2 - l + r, (n * n - i * i) / 2 + l - r}) << '\n';
            if ((n / i) % 2)
                ans = min({ans, (n * n - i * i) / 2 + i * i - l + r, (n * n - i * i) / 2 + l - r});
            else
                ans = min({ans, (n * n) / 2 - l + r, (n * n) / 2 + l - r});
        }
    cout << ans << '\n';
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:18:12: warning: unused variable 'm' [-Wunused-variable]
   18 |     int n, m, k, ans = 100000000000;
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 2332 KB Output is correct
2 Correct 20 ms 876 KB Output is correct
3 Correct 47 ms 1516 KB Output is correct
4 Correct 47 ms 1772 KB Output is correct
5 Correct 65 ms 2028 KB Output is correct
6 Correct 43 ms 1388 KB Output is correct
7 Correct 9 ms 492 KB Output is correct
8 Correct 42 ms 1388 KB Output is correct
9 Correct 112 ms 3308 KB Output is correct
10 Correct 59 ms 1900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 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 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 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 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 27 ms 1224 KB Output is correct
17 Correct 81 ms 3004 KB Output is correct
18 Correct 96 ms 3436 KB Output is correct
19 Correct 120 ms 3052 KB Output is correct
20 Correct 133 ms 3436 KB Output is correct
21 Correct 78 ms 2796 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 44 ms 1644 KB Output is correct
24 Correct 88 ms 3180 KB Output is correct
25 Correct 9 ms 620 KB Output is correct
26 Correct 56 ms 2028 KB Output is correct
27 Correct 69 ms 2412 KB Output is correct
28 Correct 106 ms 3308 KB Output is correct
29 Correct 31 ms 1388 KB Output is correct
30 Correct 4 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 75 ms 2332 KB Output is correct
2 Correct 20 ms 876 KB Output is correct
3 Correct 47 ms 1516 KB Output is correct
4 Correct 47 ms 1772 KB Output is correct
5 Correct 65 ms 2028 KB Output is correct
6 Correct 43 ms 1388 KB Output is correct
7 Correct 9 ms 492 KB Output is correct
8 Correct 42 ms 1388 KB Output is correct
9 Correct 112 ms 3308 KB Output is correct
10 Correct 59 ms 1900 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 27 ms 1224 KB Output is correct
27 Correct 81 ms 3004 KB Output is correct
28 Correct 96 ms 3436 KB Output is correct
29 Correct 120 ms 3052 KB Output is correct
30 Correct 133 ms 3436 KB Output is correct
31 Correct 78 ms 2796 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 44 ms 1644 KB Output is correct
34 Correct 88 ms 3180 KB Output is correct
35 Correct 9 ms 620 KB Output is correct
36 Correct 56 ms 2028 KB Output is correct
37 Correct 69 ms 2412 KB Output is correct
38 Correct 106 ms 3308 KB Output is correct
39 Correct 31 ms 1388 KB Output is correct
40 Correct 4 ms 364 KB Output is correct
41 Correct 129 ms 3052 KB Output is correct
42 Correct 115 ms 3308 KB Output is correct
43 Correct 138 ms 2924 KB Output is correct
44 Correct 116 ms 3180 KB Output is correct
45 Correct 134 ms 3436 KB Output is correct
46 Correct 165 ms 3396 KB Output is correct
47 Correct 104 ms 3052 KB Output is correct
48 Correct 116 ms 3052 KB Output is correct
49 Correct 103 ms 3052 KB Output is correct
50 Correct 315 ms 3308 KB Output is correct
51 Correct 333 ms 3308 KB Output is correct
52 Correct 300 ms 3180 KB Output is correct
53 Correct 328 ms 3436 KB Output is correct
54 Correct 302 ms 3180 KB Output is correct
55 Correct 337 ms 3564 KB Output is correct
56 Correct 288 ms 3064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 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 75 ms 2332 KB Output is correct
10 Correct 20 ms 876 KB Output is correct
11 Correct 47 ms 1516 KB Output is correct
12 Correct 47 ms 1772 KB Output is correct
13 Correct 65 ms 2028 KB Output is correct
14 Correct 43 ms 1388 KB Output is correct
15 Correct 9 ms 492 KB Output is correct
16 Correct 42 ms 1388 KB Output is correct
17 Correct 112 ms 3308 KB Output is correct
18 Correct 59 ms 1900 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 27 ms 1224 KB Output is correct
35 Correct 81 ms 3004 KB Output is correct
36 Correct 96 ms 3436 KB Output is correct
37 Correct 120 ms 3052 KB Output is correct
38 Correct 133 ms 3436 KB Output is correct
39 Correct 78 ms 2796 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 44 ms 1644 KB Output is correct
42 Correct 88 ms 3180 KB Output is correct
43 Correct 9 ms 620 KB Output is correct
44 Correct 56 ms 2028 KB Output is correct
45 Correct 69 ms 2412 KB Output is correct
46 Correct 106 ms 3308 KB Output is correct
47 Correct 31 ms 1388 KB Output is correct
48 Correct 4 ms 364 KB Output is correct
49 Correct 129 ms 3052 KB Output is correct
50 Correct 115 ms 3308 KB Output is correct
51 Correct 138 ms 2924 KB Output is correct
52 Correct 116 ms 3180 KB Output is correct
53 Correct 134 ms 3436 KB Output is correct
54 Correct 165 ms 3396 KB Output is correct
55 Correct 104 ms 3052 KB Output is correct
56 Correct 116 ms 3052 KB Output is correct
57 Correct 103 ms 3052 KB Output is correct
58 Correct 315 ms 3308 KB Output is correct
59 Correct 333 ms 3308 KB Output is correct
60 Correct 300 ms 3180 KB Output is correct
61 Correct 328 ms 3436 KB Output is correct
62 Correct 302 ms 3180 KB Output is correct
63 Correct 337 ms 3564 KB Output is correct
64 Correct 288 ms 3064 KB Output is correct
65 Correct 1 ms 364 KB Output is correct
66 Incorrect 0 ms 364 KB Output isn't correct
67 Halted 0 ms 0 KB -