Submission #92888

# Submission time Handle Problem Language Result Execution time Memory
92888 2019-01-05T12:35:40 Z muradeyn Chessboard (IZhO18_chessboard) C++14
70 / 100
1063 ms 4344 KB
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 100001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);

using namespace std;

struct rect{
    int a , b , c , d;
};

rect sub[SIZE];

intt need;

vector<intt>ans;

intt n , k;

vector<intt>dv;

int main()
{
    FAST_READ;
    cin>>n>>k;
    for (int i = 0;i<k;i++)cin>>sub[i].a>>sub[i].b>>sub[i].c>>sub[i].d;
    dv.push_back(1);
    for (int i = 2;i * i <= n;i++) {
        if (n % i == 0) {
            dv.push_back(i);
            if (i * i == n)continue;
            dv.push_back(n / i);
        }
    }
    for (intt i : dv) {
        need = ( (n / i + 1) / 2 ) * ( (n / i + 1) / 2 );
        need += (n / i / 2) * (n / i / 2);
        need *= (i * i);
        for (int j = 0;j < k;j++) {
            int row , column;
            if (sub[j].a % i == 0)row = sub[j].a / i;
            else row = (sub[j].a + i) / i;
            if (sub[j].b % i == 0)column = sub[j].b / i;
            else column = (sub[j].b + i) / i;
            if (row % 2 == column % 2) need--;
            else need++;
        }
        ans.push_back(need);
        need = n * n;
        need -= ( (n / i + 1) / 2 ) * ( (n / i + 1) / 2 ) * (i * i);
        need -= (n / i / 2) * (n / i / 2) * (i * i);
        for (int j = 0;j < k;j++) {
            int row , column;
            if (sub[j].a % i == 0)row = sub[j].a / i;
            else row = (sub[j].a + i) / i;
            if (sub[j].b % i == 0)column = sub[j].b / i;
            else column = (sub[j].b + i) / i;
            if (row % 2 == column % 2) need++;
            else need--;
        }
        ans.push_back(need);
    }
    sort(ans.begin(),ans.end());
    cout<<ans[0]<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1272 KB Output is correct
2 Correct 8 ms 888 KB Output is correct
3 Correct 17 ms 1912 KB Output is correct
4 Correct 18 ms 1952 KB Output is correct
5 Correct 23 ms 2552 KB Output is correct
6 Correct 15 ms 1660 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 15 ms 1656 KB Output is correct
9 Correct 36 ms 3832 KB Output is correct
10 Correct 21 ms 2296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 15 ms 888 KB Output is correct
17 Correct 29 ms 1768 KB Output is correct
18 Correct 50 ms 1992 KB Output is correct
19 Correct 222 ms 1912 KB Output is correct
20 Correct 246 ms 2168 KB Output is correct
21 Correct 28 ms 1784 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 36 ms 1144 KB Output is correct
24 Correct 46 ms 1784 KB Output is correct
25 Correct 9 ms 632 KB Output is correct
26 Correct 30 ms 1400 KB Output is correct
27 Correct 45 ms 1528 KB Output is correct
28 Correct 49 ms 1912 KB Output is correct
29 Correct 13 ms 1016 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 1272 KB Output is correct
2 Correct 8 ms 888 KB Output is correct
3 Correct 17 ms 1912 KB Output is correct
4 Correct 18 ms 1952 KB Output is correct
5 Correct 23 ms 2552 KB Output is correct
6 Correct 15 ms 1660 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 15 ms 1656 KB Output is correct
9 Correct 36 ms 3832 KB Output is correct
10 Correct 21 ms 2296 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 15 ms 888 KB Output is correct
27 Correct 29 ms 1768 KB Output is correct
28 Correct 50 ms 1992 KB Output is correct
29 Correct 222 ms 1912 KB Output is correct
30 Correct 246 ms 2168 KB Output is correct
31 Correct 28 ms 1784 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 36 ms 1144 KB Output is correct
34 Correct 46 ms 1784 KB Output is correct
35 Correct 9 ms 632 KB Output is correct
36 Correct 30 ms 1400 KB Output is correct
37 Correct 45 ms 1528 KB Output is correct
38 Correct 49 ms 1912 KB Output is correct
39 Correct 13 ms 1016 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 182 ms 3676 KB Output is correct
42 Correct 54 ms 4088 KB Output is correct
43 Correct 101 ms 3704 KB Output is correct
44 Correct 52 ms 4092 KB Output is correct
45 Correct 39 ms 4220 KB Output is correct
46 Correct 202 ms 4088 KB Output is correct
47 Correct 34 ms 3704 KB Output is correct
48 Correct 79 ms 3832 KB Output is correct
49 Correct 48 ms 3704 KB Output is correct
50 Correct 969 ms 3960 KB Output is correct
51 Correct 1020 ms 4256 KB Output is correct
52 Correct 951 ms 3852 KB Output is correct
53 Correct 1006 ms 4216 KB Output is correct
54 Correct 945 ms 3992 KB Output is correct
55 Correct 1063 ms 4344 KB Output is correct
56 Correct 920 ms 3708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 25 ms 1272 KB Output is correct
10 Correct 8 ms 888 KB Output is correct
11 Correct 17 ms 1912 KB Output is correct
12 Correct 18 ms 1952 KB Output is correct
13 Correct 23 ms 2552 KB Output is correct
14 Correct 15 ms 1660 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 15 ms 1656 KB Output is correct
17 Correct 36 ms 3832 KB Output is correct
18 Correct 21 ms 2296 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 15 ms 888 KB Output is correct
35 Correct 29 ms 1768 KB Output is correct
36 Correct 50 ms 1992 KB Output is correct
37 Correct 222 ms 1912 KB Output is correct
38 Correct 246 ms 2168 KB Output is correct
39 Correct 28 ms 1784 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 36 ms 1144 KB Output is correct
42 Correct 46 ms 1784 KB Output is correct
43 Correct 9 ms 632 KB Output is correct
44 Correct 30 ms 1400 KB Output is correct
45 Correct 45 ms 1528 KB Output is correct
46 Correct 49 ms 1912 KB Output is correct
47 Correct 13 ms 1016 KB Output is correct
48 Correct 3 ms 376 KB Output is correct
49 Correct 182 ms 3676 KB Output is correct
50 Correct 54 ms 4088 KB Output is correct
51 Correct 101 ms 3704 KB Output is correct
52 Correct 52 ms 4092 KB Output is correct
53 Correct 39 ms 4220 KB Output is correct
54 Correct 202 ms 4088 KB Output is correct
55 Correct 34 ms 3704 KB Output is correct
56 Correct 79 ms 3832 KB Output is correct
57 Correct 48 ms 3704 KB Output is correct
58 Correct 969 ms 3960 KB Output is correct
59 Correct 1020 ms 4256 KB Output is correct
60 Correct 951 ms 3852 KB Output is correct
61 Correct 1006 ms 4216 KB Output is correct
62 Correct 945 ms 3992 KB Output is correct
63 Correct 1063 ms 4344 KB Output is correct
64 Correct 920 ms 3708 KB Output is correct
65 Correct 2 ms 504 KB Output is correct
66 Incorrect 2 ms 376 KB Output isn't correct
67 Halted 0 ms 0 KB -