Submission #378597

# Submission time Handle Problem Language Result Execution time Memory
378597 2021-03-17T02:07:36 Z LittleCube Chessboard (IZhO18_chessboard) C++14
0 / 100
76 ms 2332 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;
    cin >> n >> k;
    vector<point> v(k);
    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 <= sqrt(n); i++)
        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';
            ans = min({ans, (n * n - i * i) / 2 + i * i - l + r, (n * n - i * i) / 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;
      |            ^
chessboard.cpp:18:18: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |     int n, m, k, ans;
      |                  ^~~
# 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 76 ms 2332 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 76 ms 2332 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 -