Submission #90285

# Submission time Handle Problem Language Result Execution time Memory
90285 2018-12-21T04:42:48 Z HardNut Chessboard (IZhO18_chessboard) C++17
70 / 100
392 ms 6736 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;
const long long INF = 1e18 + 5;
const int MAXN = 1e6;
const int base = 317;

typedef long long ll;

const ll bs = 1e5 + 1;
const ll mod = 998244353;

ll ans = INF, n, k, xx[N], yy[N];

ll calc(ll x) {
    ll res1 = 0, res2 = 0;
    for (int i = 1; i <= k; i++) {
        if ((xx[i] / x) % 2 == (yy[i] / x) % 2) {
            res1++;
        } else {
            res2++;
        }
    }
    ll c1 = (n / x) * (n / x) / 2 * x * x;
    ll c2 = n * n - c1;
    return min(c1 - res2 + res1, c2 - res1 + res2);
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= k; i++) {
        cin >> xx[i] >> yy[i] >> xx[i] >> yy[i];
        xx[i]--;
        yy[i]--;
    }
    for (int i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            ans = min(ans, calc(i));
            if (i != 1)
                ans = min(ans, calc(n / i));
        }
    }
    cout << ans;
    return 0;
}
/*

*/

Compilation message

chessboard.cpp:31:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1532 KB Output is correct
2 Correct 7 ms 1532 KB Output is correct
3 Correct 15 ms 2508 KB Output is correct
4 Correct 17 ms 3448 KB Output is correct
5 Correct 22 ms 4724 KB Output is correct
6 Correct 14 ms 4724 KB Output is correct
7 Correct 11 ms 4724 KB Output is correct
8 Correct 14 ms 4724 KB Output is correct
9 Correct 35 ms 5344 KB Output is correct
10 Correct 20 ms 5344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5344 KB Output is correct
2 Correct 2 ms 5344 KB Output is correct
3 Correct 2 ms 5344 KB Output is correct
4 Correct 2 ms 5344 KB Output is correct
5 Correct 2 ms 5344 KB Output is correct
6 Correct 2 ms 5344 KB Output is correct
7 Correct 2 ms 5344 KB Output is correct
8 Correct 2 ms 5344 KB Output is correct
9 Correct 2 ms 5344 KB Output is correct
10 Correct 2 ms 5344 KB Output is correct
11 Correct 2 ms 5344 KB Output is correct
12 Correct 2 ms 5344 KB Output is correct
13 Correct 2 ms 5344 KB Output is correct
14 Correct 2 ms 5344 KB Output is correct
15 Correct 3 ms 5344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5344 KB Output is correct
2 Correct 2 ms 5344 KB Output is correct
3 Correct 2 ms 5344 KB Output is correct
4 Correct 2 ms 5344 KB Output is correct
5 Correct 2 ms 5344 KB Output is correct
6 Correct 2 ms 5344 KB Output is correct
7 Correct 2 ms 5344 KB Output is correct
8 Correct 2 ms 5344 KB Output is correct
9 Correct 2 ms 5344 KB Output is correct
10 Correct 2 ms 5344 KB Output is correct
11 Correct 2 ms 5344 KB Output is correct
12 Correct 2 ms 5344 KB Output is correct
13 Correct 2 ms 5344 KB Output is correct
14 Correct 2 ms 5344 KB Output is correct
15 Correct 3 ms 5344 KB Output is correct
16 Correct 12 ms 5344 KB Output is correct
17 Correct 28 ms 5344 KB Output is correct
18 Correct 37 ms 5492 KB Output is correct
19 Correct 95 ms 5492 KB Output is correct
20 Correct 103 ms 5616 KB Output is correct
21 Correct 26 ms 5616 KB Output is correct
22 Correct 2 ms 5616 KB Output is correct
23 Correct 22 ms 5616 KB Output is correct
24 Correct 35 ms 5616 KB Output is correct
25 Correct 6 ms 5616 KB Output is correct
26 Correct 22 ms 5616 KB Output is correct
27 Correct 30 ms 5616 KB Output is correct
28 Correct 35 ms 5616 KB Output is correct
29 Correct 12 ms 5616 KB Output is correct
30 Correct 3 ms 5616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1532 KB Output is correct
2 Correct 7 ms 1532 KB Output is correct
3 Correct 15 ms 2508 KB Output is correct
4 Correct 17 ms 3448 KB Output is correct
5 Correct 22 ms 4724 KB Output is correct
6 Correct 14 ms 4724 KB Output is correct
7 Correct 11 ms 4724 KB Output is correct
8 Correct 14 ms 4724 KB Output is correct
9 Correct 35 ms 5344 KB Output is correct
10 Correct 20 ms 5344 KB Output is correct
11 Correct 2 ms 5344 KB Output is correct
12 Correct 2 ms 5344 KB Output is correct
13 Correct 2 ms 5344 KB Output is correct
14 Correct 2 ms 5344 KB Output is correct
15 Correct 2 ms 5344 KB Output is correct
16 Correct 2 ms 5344 KB Output is correct
17 Correct 2 ms 5344 KB Output is correct
18 Correct 2 ms 5344 KB Output is correct
19 Correct 2 ms 5344 KB Output is correct
20 Correct 2 ms 5344 KB Output is correct
21 Correct 2 ms 5344 KB Output is correct
22 Correct 2 ms 5344 KB Output is correct
23 Correct 2 ms 5344 KB Output is correct
24 Correct 2 ms 5344 KB Output is correct
25 Correct 3 ms 5344 KB Output is correct
26 Correct 12 ms 5344 KB Output is correct
27 Correct 28 ms 5344 KB Output is correct
28 Correct 37 ms 5492 KB Output is correct
29 Correct 95 ms 5492 KB Output is correct
30 Correct 103 ms 5616 KB Output is correct
31 Correct 26 ms 5616 KB Output is correct
32 Correct 2 ms 5616 KB Output is correct
33 Correct 22 ms 5616 KB Output is correct
34 Correct 35 ms 5616 KB Output is correct
35 Correct 6 ms 5616 KB Output is correct
36 Correct 22 ms 5616 KB Output is correct
37 Correct 30 ms 5616 KB Output is correct
38 Correct 35 ms 5616 KB Output is correct
39 Correct 12 ms 5616 KB Output is correct
40 Correct 3 ms 5616 KB Output is correct
41 Correct 84 ms 5616 KB Output is correct
42 Correct 41 ms 5616 KB Output is correct
43 Correct 55 ms 5616 KB Output is correct
44 Correct 40 ms 5692 KB Output is correct
45 Correct 37 ms 6720 KB Output is correct
46 Correct 94 ms 6720 KB Output is correct
47 Correct 32 ms 6720 KB Output is correct
48 Correct 47 ms 6720 KB Output is correct
49 Correct 36 ms 6720 KB Output is correct
50 Correct 371 ms 6720 KB Output is correct
51 Correct 387 ms 6720 KB Output is correct
52 Correct 354 ms 6720 KB Output is correct
53 Correct 384 ms 6720 KB Output is correct
54 Correct 351 ms 6720 KB Output is correct
55 Correct 392 ms 6736 KB Output is correct
56 Correct 339 ms 6736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 484 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 620 KB Output is correct
9 Correct 24 ms 1532 KB Output is correct
10 Correct 7 ms 1532 KB Output is correct
11 Correct 15 ms 2508 KB Output is correct
12 Correct 17 ms 3448 KB Output is correct
13 Correct 22 ms 4724 KB Output is correct
14 Correct 14 ms 4724 KB Output is correct
15 Correct 11 ms 4724 KB Output is correct
16 Correct 14 ms 4724 KB Output is correct
17 Correct 35 ms 5344 KB Output is correct
18 Correct 20 ms 5344 KB Output is correct
19 Correct 2 ms 5344 KB Output is correct
20 Correct 2 ms 5344 KB Output is correct
21 Correct 2 ms 5344 KB Output is correct
22 Correct 2 ms 5344 KB Output is correct
23 Correct 2 ms 5344 KB Output is correct
24 Correct 2 ms 5344 KB Output is correct
25 Correct 2 ms 5344 KB Output is correct
26 Correct 2 ms 5344 KB Output is correct
27 Correct 2 ms 5344 KB Output is correct
28 Correct 2 ms 5344 KB Output is correct
29 Correct 2 ms 5344 KB Output is correct
30 Correct 2 ms 5344 KB Output is correct
31 Correct 2 ms 5344 KB Output is correct
32 Correct 2 ms 5344 KB Output is correct
33 Correct 3 ms 5344 KB Output is correct
34 Correct 12 ms 5344 KB Output is correct
35 Correct 28 ms 5344 KB Output is correct
36 Correct 37 ms 5492 KB Output is correct
37 Correct 95 ms 5492 KB Output is correct
38 Correct 103 ms 5616 KB Output is correct
39 Correct 26 ms 5616 KB Output is correct
40 Correct 2 ms 5616 KB Output is correct
41 Correct 22 ms 5616 KB Output is correct
42 Correct 35 ms 5616 KB Output is correct
43 Correct 6 ms 5616 KB Output is correct
44 Correct 22 ms 5616 KB Output is correct
45 Correct 30 ms 5616 KB Output is correct
46 Correct 35 ms 5616 KB Output is correct
47 Correct 12 ms 5616 KB Output is correct
48 Correct 3 ms 5616 KB Output is correct
49 Correct 84 ms 5616 KB Output is correct
50 Correct 41 ms 5616 KB Output is correct
51 Correct 55 ms 5616 KB Output is correct
52 Correct 40 ms 5692 KB Output is correct
53 Correct 37 ms 6720 KB Output is correct
54 Correct 94 ms 6720 KB Output is correct
55 Correct 32 ms 6720 KB Output is correct
56 Correct 47 ms 6720 KB Output is correct
57 Correct 36 ms 6720 KB Output is correct
58 Correct 371 ms 6720 KB Output is correct
59 Correct 387 ms 6720 KB Output is correct
60 Correct 354 ms 6720 KB Output is correct
61 Correct 384 ms 6720 KB Output is correct
62 Correct 351 ms 6720 KB Output is correct
63 Correct 392 ms 6736 KB Output is correct
64 Correct 339 ms 6736 KB Output is correct
65 Correct 1 ms 6736 KB Output is correct
66 Incorrect 1 ms 6736 KB Output isn't correct
67 Halted 0 ms 0 KB -