Submission #378834

# Submission time Handle Problem Language Result Execution time Memory
378834 2021-03-17T05:48:48 Z LittleCube Chessboard (IZhO18_chessboard) C++14
0 / 100
107 ms 5228 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

/*************************************
 * 
 *  Without Subtask 4 : 70 points
 *  
 */
struct point
{
    int x1, y1, x2, y2;
};

signed main()
{

    int n, m, k, ans = 100000000000;
    cin >> n >> k;
    vector<point> v(k);
    set<int> fac;
    for (int i = 0; i < k; i++)
        cin >> v[i].x1 >> v[i].y1 >> v[i].x2 >> v[i].y2;

    for (int i = 1; i <= n; i++)
    {
        fac.insert(i);
        fac.insert(n / i);
    }
    for (int i : fac)
        if (n % i == 0)
        {
            int l = 0, r = 0;
            for (auto j : v)
                if (((j.x1 + i - 1) / i + (j.y1 + i - 1) / i) % 2)
                    r++;
                else
                    l++;
            //cout << i << " " << min({(n * n - i * i + 1) / 2 - l + r, (n * n - i * i) / 2 + l - r}) << '\n';
            if ((n / i) % 2)
                ans = min({ans, (n * n - i * i) / 2 + i * i - l + r, (n * n - i * i) / 2 + l - r});
            else
                ans = min({ans, (n * n) / 2 - l + r, (n * n) / 2 + l - r});
        }
    cout << ans << '\n';
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:18:12: warning: unused variable 'm' [-Wunused-variable]
   18 |     int n, m, k, ans = 100000000000;
      |            ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 5228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 5228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -