Submission #488057

# Submission time Handle Problem Language Result Execution time Memory
488057 2021-11-17T14:10:40 Z nickmet2004 Chessboard (IZhO18_chessboard) C++11
0 / 100
27 ms 3264 KB
#include<bits/stdc++.h>

using namespace std;
const int N= 1e5 + 5;
int n , k;
int A[N] , B[N] , C[N] , D[N];
int G[N][2];
int ans = 2e9;
void q(int x){
    int sz = n / x;
    for(int i = 0; i < k; ++i){
        G[B[i] / x][(A[i] / x) % 2]++;
    }
    int Y = 0 , L = sz / 2 , ok = 0;
    if((sz / 2) % 2 == 1)ok = 1;
    L += ok;
    for(int i= 0;i < sz; ++i){
        Y += L * x * x - G[i][0] + G[i][1];
        if(i & 1) L -= ok;
        else L += ok;
    }
    ans = min(Y , ans);
    L = sz/2;
    Y = 0;
    for(int i = 0; i < sz; ++i){
        Y += G[i][0] + L * x * x - G[i][1];
        if(i & 1) L += ok;
        else L -= ok;
        G[i][0] = G[i][1] = 0;
    }
    ans = min(Y , ans);
}
int main (){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for(int i = 0; i < k; ++i){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        --A[i] , --B[i] , --C[i] , --D[i];
    }
    for(int i = 1; i * i <= n; ++i){
        if(n % i ==0){
            q(n / i);
            if(n / i != i) q(i);
        }
    }
    cout << ans;
return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -