Submission #43349

# Submission time Handle Problem Language Result Execution time Memory
43349 2018-03-14T04:04:42 Z nickyrio Chessboard (IZhO18_chessboard) C++14
0 / 100
29 ms 3996 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)
#define y1 sdfjksdjf
#define x1 poieopwriwe
#define x2 wkejlks
#define y2 skldjflksd
using namespace std;
long long n, k, x1[N], x2[N], y1[N], y2[N];

long long solve(int l, int color) {
    long long ans = n * n / 2;
    REP(i, k) {
        if (color ^ ((x1[i] / l) % 2) == (y1[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 >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    REP(i, k) x1[i]--,x2[i]--,y1[i]--,y2[i]--;
    FOR(i, 1, sqrt(n)) if (n % i == 0) {
        ans = min(ans, solve(i, 0));
        ans = min(ans, solve(i, 1));
    }
    cout << ans;
    #ifdef NERO
    clock_t etime = clock();
    cerr << "Execution time: " << (etime - stime) / CLOCKS_PER_SEC * 1000 << " ms.";
    #endif // NERO
}

Compilation message

chessboard.cpp: In function 'long long int solve(int, int)':
chessboard.cpp:23:39: warning: suggest parentheses around comparison in operand of '^' [-Wparentheses]
         if (color ^ ((x1[i] / l) % 2) == (y1[i] / l) % 2) ans--;
                                       ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
2 Incorrect 1 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 3996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 29 ms 3996 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 Incorrect 1 ms 356 KB Output isn't correct
3 Halted 0 ms 0 KB -