Submission #43745

# Submission time Handle Problem Language Result Execution time Memory
43745 2018-03-22T03:02:59 Z nickyrio Chessboard (IZhO18_chessboard) C++14
39 / 100
210 ms 17616 KB
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define DEBUG(x) { cerr << #x << '=' << x << endl; }
#define Arr(a, l, r) { cerr << #a << " = {"; FOR(_, l, r) cerr << ' ' << a[_]; cerr << "}\n"; }
#define N 1001000
#define pp pair<int, int>
#define endl '\n'
#define IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define taskname ""
#define bit(S, i) (((S) >> (i)) & 1)
using namespace std;
long long n, k, xx1[N], xx2[N], xy1[N], xy2[N];

long long solve(int l, int color) {// color = 0 -> Top-left is black
    long long ans = ((1ll * (n / l) * (n / l) + 1 - color) / 2) * l * l ;
    REP(i, k) {
        if (color ^ (((xx1[i] / l) % 2) == (xy1[i] / l) % 2)) ans--;
        else ans++;
    }
    return ans;
} 
int main() {
    #ifdef NERO
    freopen("test.inp","r",stdin);
    freopen("test.out","w",stdout);
    clock_t stime = clock();
    #endif //NERO
    IO;
    cin >> n >> k;
    long long ans = 1e9;
    REP(i, k) cin >> xx1[i] >> xy1[i] >> xx2[i] >> xy2[i];
    REP(i, k) xx1[i]--,xx2[i]--,xy1[i]--,xy2[i]--;
    FOR(i, 1, sqrt(n)) if (n % i == 0) {
        ans = min(ans, solve(i, 0));
        ans = min(ans, solve(i, 1));
        if (i != 1) ans = min(ans, solve(n / i, 0));
        if (i != 1) ans = min(ans, solve(n / i, 1));
    }
    cout << ans;
    #ifdef NERO
    clock_t etime = clock();
    cerr << "Execution time: " << (etime - stime) / CLOCKS_PER_SEC * 1000 << " ms.";
    #endif // NERO
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 2 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 2776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2776 KB Output is correct
2 Correct 2 ms 2776 KB Output is correct
3 Correct 2 ms 2776 KB Output is correct
4 Correct 3 ms 2776 KB Output is correct
5 Correct 3 ms 2776 KB Output is correct
6 Correct 2 ms 2776 KB Output is correct
7 Correct 3 ms 2776 KB Output is correct
8 Correct 3 ms 2776 KB Output is correct
9 Correct 2 ms 2776 KB Output is correct
10 Correct 2 ms 2776 KB Output is correct
11 Correct 2 ms 2776 KB Output is correct
12 Correct 2 ms 2776 KB Output is correct
13 Correct 3 ms 2776 KB Output is correct
14 Correct 2 ms 2776 KB Output is correct
15 Correct 2 ms 2776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2776 KB Output is correct
2 Correct 2 ms 2776 KB Output is correct
3 Correct 2 ms 2776 KB Output is correct
4 Correct 3 ms 2776 KB Output is correct
5 Correct 3 ms 2776 KB Output is correct
6 Correct 2 ms 2776 KB Output is correct
7 Correct 3 ms 2776 KB Output is correct
8 Correct 3 ms 2776 KB Output is correct
9 Correct 2 ms 2776 KB Output is correct
10 Correct 2 ms 2776 KB Output is correct
11 Correct 2 ms 2776 KB Output is correct
12 Correct 2 ms 2776 KB Output is correct
13 Correct 3 ms 2776 KB Output is correct
14 Correct 2 ms 2776 KB Output is correct
15 Correct 2 ms 2776 KB Output is correct
16 Correct 15 ms 2776 KB Output is correct
17 Correct 51 ms 5476 KB Output is correct
18 Correct 52 ms 7456 KB Output is correct
19 Correct 162 ms 8696 KB Output is correct
20 Correct 210 ms 10380 KB Output is correct
21 Correct 32 ms 11208 KB Output is correct
22 Correct 2 ms 11208 KB Output is correct
23 Correct 34 ms 11208 KB Output is correct
24 Correct 46 ms 13624 KB Output is correct
25 Correct 7 ms 13624 KB Output is correct
26 Correct 30 ms 13664 KB Output is correct
27 Correct 44 ms 15172 KB Output is correct
28 Correct 51 ms 17616 KB Output is correct
29 Correct 21 ms 17616 KB Output is correct
30 Correct 3 ms 17616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 2776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 356 KB Output is correct
3 Correct 2 ms 552 KB Output is correct
4 Correct 2 ms 552 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 2 ms 552 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 2 ms 668 KB Output is correct
9 Incorrect 31 ms 2776 KB Output isn't correct
10 Halted 0 ms 0 KB -