Submission #343277

# Submission time Handle Problem Language Result Execution time Memory
343277 2021-01-03T15:38:48 Z Sprdalo Chessboard (IZhO18_chessboard) C++17
0 / 100
23 ms 620 KB
#include <bits/stdc++.h>

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

void no(){
    cout << "-1\n";
    exit(0);
}

signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

    int n, k;
    cin >> n >> k;

    vi d;
    for (int i = 1; i < n; ++i){
        if (n % i == 0){
            d.push_back(i);
        }
    }

    int len = d.size();
    vi b(len);
    for (int i = 0; i < k; ++i){
        int x1,y1,x2,y2;
        cin >> x1>>y1>>x2>>y2;

        if (x1!=x2 || y1 != y2)
            return 0;
        --x1;
        --y1;

        for (int j = 0; j < len; ++j){
            int t = d[j];

            bool b1 = (x1%(2*t) < t), b2 = (y1%(2*t) < t);
            if (b1 == b2){
                b[j]++;
            }
        }
    }

    int sol = n*n;
    for (int i = 0; i < len; ++i){
        int t = d[i];
        int c = n/t;

        if (c % 2){
            c += ((n/t+1)/2);
        }
        c *= n/(2*t);
        c *= t*t;

        int res = k-b[i] + c-b[i];
        sol = min(sol, res);

        b[i] = k-b[i];
        c = n/t;
        if (c%2){
            c += n/(2*t);
        }
        c *= t * t;
        c *= n/(2*t);

        res = k+c - 2 * b[i];
        sol = min(sol, res);
    }

    cout << sol << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -