Submission #747062

# Submission time Handle Problem Language Result Execution time Memory
747062 2023-05-23T14:41:05 Z heeheeheehaaw Chessboard (IZhO18_chessboard) C++17
70 / 100
309 ms 5816 KB
#include <iostream>
#include <vector>
#define int long long

using namespace std;

int a[1005][1005];
int spw[1005][1005], spb[1005][1005];
int x1[100005], x2[100005], y1[100005], y2[100005];

signed main()
{
    int s1 = 0, s2 = 0;
    int n, k;
    cin>>n>>k;

    vector<int> divs;
    for(int i = 1; i * i <= n; i++)
        if(n % i == 0)
        {
            divs.push_back(i);
            if(i * i != n && i != 1)
                divs.push_back(n / i);
        }

    for(int i = 1; i <= k; i++)
        cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];

    int minn = n * n;
    for(auto d : divs)
    {
        int s1 = 0, s2 = 0;
        for(int i = 1; i <= k; i++)
        {
            int c1 = (x1[i] - 1) / d + 1;
            int c2 = (y1[i] - 1) / d + 1;
            if((c1 + c2) % 2 == 0)
                s1++;
            else
                s2++;
        }

        int d1 = n * n, d2 = n * n;
        int nli = n / d / 2, nlp = n / d / 2;
        if((n / d) % 2 == 1) nli++;

        d2 -= (d * d * (nli * nli + nlp * nlp));
        d1 = n * n - d2;
        int ans = min(d1 - s1 + s2, d2 - s2 + s1);
        minn = min(minn, ans);
    }

    cout<<minn<<'\n';

    return 0;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:13:9: warning: unused variable 's1' [-Wunused-variable]
   13 |     int s1 = 0, s2 = 0;
      |         ^~
chessboard.cpp:13:17: warning: unused variable 's2' [-Wunused-variable]
   13 |     int s1 = 0, s2 = 0;
      |                 ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 2244 KB Output is correct
2 Correct 16 ms 748 KB Output is correct
3 Correct 41 ms 1528 KB Output is correct
4 Correct 40 ms 1740 KB Output is correct
5 Correct 57 ms 1888 KB Output is correct
6 Correct 35 ms 1356 KB Output is correct
7 Correct 9 ms 464 KB Output is correct
8 Correct 45 ms 1404 KB Output is correct
9 Correct 92 ms 3076 KB Output is correct
10 Correct 58 ms 1864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 23 ms 1108 KB Output is correct
17 Correct 72 ms 2912 KB Output is correct
18 Correct 85 ms 3404 KB Output is correct
19 Correct 109 ms 2944 KB Output is correct
20 Correct 127 ms 3440 KB Output is correct
21 Correct 66 ms 2800 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 45 ms 1604 KB Output is correct
24 Correct 74 ms 3020 KB Output is correct
25 Correct 8 ms 588 KB Output is correct
26 Correct 47 ms 2080 KB Output is correct
27 Correct 57 ms 2356 KB Output is correct
28 Correct 82 ms 3228 KB Output is correct
29 Correct 28 ms 1288 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 2244 KB Output is correct
2 Correct 16 ms 748 KB Output is correct
3 Correct 41 ms 1528 KB Output is correct
4 Correct 40 ms 1740 KB Output is correct
5 Correct 57 ms 1888 KB Output is correct
6 Correct 35 ms 1356 KB Output is correct
7 Correct 9 ms 464 KB Output is correct
8 Correct 45 ms 1404 KB Output is correct
9 Correct 92 ms 3076 KB Output is correct
10 Correct 58 ms 1864 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 23 ms 1108 KB Output is correct
27 Correct 72 ms 2912 KB Output is correct
28 Correct 85 ms 3404 KB Output is correct
29 Correct 109 ms 2944 KB Output is correct
30 Correct 127 ms 3440 KB Output is correct
31 Correct 66 ms 2800 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 45 ms 1604 KB Output is correct
34 Correct 74 ms 3020 KB Output is correct
35 Correct 8 ms 588 KB Output is correct
36 Correct 47 ms 2080 KB Output is correct
37 Correct 57 ms 2356 KB Output is correct
38 Correct 82 ms 3228 KB Output is correct
39 Correct 28 ms 1288 KB Output is correct
40 Correct 3 ms 340 KB Output is correct
41 Correct 118 ms 2888 KB Output is correct
42 Correct 100 ms 5388 KB Output is correct
43 Correct 101 ms 4844 KB Output is correct
44 Correct 98 ms 5336 KB Output is correct
45 Correct 101 ms 5616 KB Output is correct
46 Correct 130 ms 5460 KB Output is correct
47 Correct 108 ms 5000 KB Output is correct
48 Correct 107 ms 5124 KB Output is correct
49 Correct 90 ms 4876 KB Output is correct
50 Correct 267 ms 5320 KB Output is correct
51 Correct 288 ms 5652 KB Output is correct
52 Correct 267 ms 5196 KB Output is correct
53 Correct 286 ms 5580 KB Output is correct
54 Correct 279 ms 5172 KB Output is correct
55 Correct 309 ms 5816 KB Output is correct
56 Correct 265 ms 5064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 73 ms 2244 KB Output is correct
10 Correct 16 ms 748 KB Output is correct
11 Correct 41 ms 1528 KB Output is correct
12 Correct 40 ms 1740 KB Output is correct
13 Correct 57 ms 1888 KB Output is correct
14 Correct 35 ms 1356 KB Output is correct
15 Correct 9 ms 464 KB Output is correct
16 Correct 45 ms 1404 KB Output is correct
17 Correct 92 ms 3076 KB Output is correct
18 Correct 58 ms 1864 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 23 ms 1108 KB Output is correct
35 Correct 72 ms 2912 KB Output is correct
36 Correct 85 ms 3404 KB Output is correct
37 Correct 109 ms 2944 KB Output is correct
38 Correct 127 ms 3440 KB Output is correct
39 Correct 66 ms 2800 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 45 ms 1604 KB Output is correct
42 Correct 74 ms 3020 KB Output is correct
43 Correct 8 ms 588 KB Output is correct
44 Correct 47 ms 2080 KB Output is correct
45 Correct 57 ms 2356 KB Output is correct
46 Correct 82 ms 3228 KB Output is correct
47 Correct 28 ms 1288 KB Output is correct
48 Correct 3 ms 340 KB Output is correct
49 Correct 118 ms 2888 KB Output is correct
50 Correct 100 ms 5388 KB Output is correct
51 Correct 101 ms 4844 KB Output is correct
52 Correct 98 ms 5336 KB Output is correct
53 Correct 101 ms 5616 KB Output is correct
54 Correct 130 ms 5460 KB Output is correct
55 Correct 108 ms 5000 KB Output is correct
56 Correct 107 ms 5124 KB Output is correct
57 Correct 90 ms 4876 KB Output is correct
58 Correct 267 ms 5320 KB Output is correct
59 Correct 288 ms 5652 KB Output is correct
60 Correct 267 ms 5196 KB Output is correct
61 Correct 286 ms 5580 KB Output is correct
62 Correct 279 ms 5172 KB Output is correct
63 Correct 309 ms 5816 KB Output is correct
64 Correct 265 ms 5064 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Incorrect 1 ms 340 KB Output isn't correct
67 Halted 0 ms 0 KB -