Submission #90102

# Submission time Handle Problem Language Result Execution time Memory
90102 2018-12-20T08:53:41 Z Abelyan Chessboard (IZhO18_chessboard) C++17
100 / 100
473 ms 68544 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N=100005;
int l1[N],l2[N],r1[N],r2[N];
ll prsp[N],prsv[N];
int main(){
    ll n;
    int k;
    cin>>n>>k;
    for (int i=0;i<k;i++){
        cin>>l1[i]>>l2[i]>>r1[i]>>r2[i];
    }
    ll mn=LLONG_MAX;
    for (ll i=1;i<n;i++){
        if (n%i)continue;
        ll qan;
        if ((n/i)%2) qan=(n*n-i*i)/2ll;
        else qan=(n*n)/2;
        prsp[0]=prsv[0]=0;
        //cout<<i<<" "<<qan<<endl;
        for (ll j=1;j<=n;j++){
            prsp[j]=prsp[j-1];
            prsv[j]=prsv[j-1];
            if (((j-1ll)/i)%2){
                prsv[j]++;
            }
            else{
                prsp[j]++;
            }
            //cout<<prsv[j]<<" "<<prsp[j]<<endl;
        }
        for (int j=0;j<k;j++){
            ll vqansp,vqansv,kqansp,kqansv;
            vqansp=prsp[r1[j]]-prsp[l1[j]-1];
            vqansv=prsv[r1[j]]-prsv[l1[j]-1];
            kqansp=prsp[r2[j]]-prsp[l2[j]-1];
            kqansv=prsv[r2[j]]-prsv[l2[j]-1];
            //cout<<vqansp<<" "<<vqansv<<" "<<kqansp<<" "<<kqansv<<endl;
            qan+=(vqansp*kqansp+vqansv*kqansv)-(vqansp*kqansv+vqansv*kqansp);
        }
        //cout<<qan<<endl;
        mn=min(mn,min(qan,n*n-qan));
    }
    cout<<mn<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 528 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 4100 KB Output is correct
2 Correct 24 ms 4100 KB Output is correct
3 Correct 63 ms 5380 KB Output is correct
4 Correct 56 ms 5380 KB Output is correct
5 Correct 82 ms 7292 KB Output is correct
6 Correct 52 ms 7600 KB Output is correct
7 Correct 13 ms 7600 KB Output is correct
8 Correct 55 ms 8676 KB Output is correct
9 Correct 127 ms 11328 KB Output is correct
10 Correct 74 ms 11732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11732 KB Output is correct
2 Correct 2 ms 11732 KB Output is correct
3 Correct 2 ms 11732 KB Output is correct
4 Correct 3 ms 11732 KB Output is correct
5 Correct 3 ms 11732 KB Output is correct
6 Correct 2 ms 11732 KB Output is correct
7 Correct 3 ms 11732 KB Output is correct
8 Correct 3 ms 11732 KB Output is correct
9 Correct 2 ms 11732 KB Output is correct
10 Correct 2 ms 11732 KB Output is correct
11 Correct 3 ms 11732 KB Output is correct
12 Correct 3 ms 11732 KB Output is correct
13 Correct 3 ms 11732 KB Output is correct
14 Correct 3 ms 11732 KB Output is correct
15 Correct 3 ms 11732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11732 KB Output is correct
2 Correct 2 ms 11732 KB Output is correct
3 Correct 2 ms 11732 KB Output is correct
4 Correct 3 ms 11732 KB Output is correct
5 Correct 3 ms 11732 KB Output is correct
6 Correct 2 ms 11732 KB Output is correct
7 Correct 3 ms 11732 KB Output is correct
8 Correct 3 ms 11732 KB Output is correct
9 Correct 2 ms 11732 KB Output is correct
10 Correct 2 ms 11732 KB Output is correct
11 Correct 3 ms 11732 KB Output is correct
12 Correct 3 ms 11732 KB Output is correct
13 Correct 3 ms 11732 KB Output is correct
14 Correct 3 ms 11732 KB Output is correct
15 Correct 3 ms 11732 KB Output is correct
16 Correct 31 ms 11732 KB Output is correct
17 Correct 92 ms 11732 KB Output is correct
18 Correct 105 ms 12024 KB Output is correct
19 Correct 104 ms 12024 KB Output is correct
20 Correct 115 ms 12024 KB Output is correct
21 Correct 87 ms 12024 KB Output is correct
22 Correct 3 ms 12024 KB Output is correct
23 Correct 46 ms 12024 KB Output is correct
24 Correct 95 ms 12024 KB Output is correct
25 Correct 11 ms 12024 KB Output is correct
26 Correct 60 ms 12024 KB Output is correct
27 Correct 80 ms 12024 KB Output is correct
28 Correct 101 ms 12024 KB Output is correct
29 Correct 39 ms 12024 KB Output is correct
30 Correct 5 ms 12024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 4100 KB Output is correct
2 Correct 24 ms 4100 KB Output is correct
3 Correct 63 ms 5380 KB Output is correct
4 Correct 56 ms 5380 KB Output is correct
5 Correct 82 ms 7292 KB Output is correct
6 Correct 52 ms 7600 KB Output is correct
7 Correct 13 ms 7600 KB Output is correct
8 Correct 55 ms 8676 KB Output is correct
9 Correct 127 ms 11328 KB Output is correct
10 Correct 74 ms 11732 KB Output is correct
11 Correct 2 ms 11732 KB Output is correct
12 Correct 2 ms 11732 KB Output is correct
13 Correct 2 ms 11732 KB Output is correct
14 Correct 3 ms 11732 KB Output is correct
15 Correct 3 ms 11732 KB Output is correct
16 Correct 2 ms 11732 KB Output is correct
17 Correct 3 ms 11732 KB Output is correct
18 Correct 3 ms 11732 KB Output is correct
19 Correct 2 ms 11732 KB Output is correct
20 Correct 2 ms 11732 KB Output is correct
21 Correct 3 ms 11732 KB Output is correct
22 Correct 3 ms 11732 KB Output is correct
23 Correct 3 ms 11732 KB Output is correct
24 Correct 3 ms 11732 KB Output is correct
25 Correct 3 ms 11732 KB Output is correct
26 Correct 31 ms 11732 KB Output is correct
27 Correct 92 ms 11732 KB Output is correct
28 Correct 105 ms 12024 KB Output is correct
29 Correct 104 ms 12024 KB Output is correct
30 Correct 115 ms 12024 KB Output is correct
31 Correct 87 ms 12024 KB Output is correct
32 Correct 3 ms 12024 KB Output is correct
33 Correct 46 ms 12024 KB Output is correct
34 Correct 95 ms 12024 KB Output is correct
35 Correct 11 ms 12024 KB Output is correct
36 Correct 60 ms 12024 KB Output is correct
37 Correct 80 ms 12024 KB Output is correct
38 Correct 101 ms 12024 KB Output is correct
39 Correct 39 ms 12024 KB Output is correct
40 Correct 5 ms 12024 KB Output is correct
41 Correct 185 ms 15836 KB Output is correct
42 Correct 149 ms 18324 KB Output is correct
43 Correct 157 ms 20120 KB Output is correct
44 Correct 142 ms 20396 KB Output is correct
45 Correct 146 ms 20476 KB Output is correct
46 Correct 195 ms 20520 KB Output is correct
47 Correct 129 ms 20684 KB Output is correct
48 Correct 142 ms 20740 KB Output is correct
49 Correct 129 ms 20740 KB Output is correct
50 Correct 392 ms 20740 KB Output is correct
51 Correct 430 ms 20740 KB Output is correct
52 Correct 423 ms 20740 KB Output is correct
53 Correct 420 ms 20868 KB Output is correct
54 Correct 402 ms 20868 KB Output is correct
55 Correct 443 ms 22924 KB Output is correct
56 Correct 392 ms 24872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 528 KB Output is correct
4 Correct 2 ms 528 KB Output is correct
5 Correct 2 ms 528 KB Output is correct
6 Correct 2 ms 560 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
9 Correct 96 ms 4100 KB Output is correct
10 Correct 24 ms 4100 KB Output is correct
11 Correct 63 ms 5380 KB Output is correct
12 Correct 56 ms 5380 KB Output is correct
13 Correct 82 ms 7292 KB Output is correct
14 Correct 52 ms 7600 KB Output is correct
15 Correct 13 ms 7600 KB Output is correct
16 Correct 55 ms 8676 KB Output is correct
17 Correct 127 ms 11328 KB Output is correct
18 Correct 74 ms 11732 KB Output is correct
19 Correct 2 ms 11732 KB Output is correct
20 Correct 2 ms 11732 KB Output is correct
21 Correct 2 ms 11732 KB Output is correct
22 Correct 3 ms 11732 KB Output is correct
23 Correct 3 ms 11732 KB Output is correct
24 Correct 2 ms 11732 KB Output is correct
25 Correct 3 ms 11732 KB Output is correct
26 Correct 3 ms 11732 KB Output is correct
27 Correct 2 ms 11732 KB Output is correct
28 Correct 2 ms 11732 KB Output is correct
29 Correct 3 ms 11732 KB Output is correct
30 Correct 3 ms 11732 KB Output is correct
31 Correct 3 ms 11732 KB Output is correct
32 Correct 3 ms 11732 KB Output is correct
33 Correct 3 ms 11732 KB Output is correct
34 Correct 31 ms 11732 KB Output is correct
35 Correct 92 ms 11732 KB Output is correct
36 Correct 105 ms 12024 KB Output is correct
37 Correct 104 ms 12024 KB Output is correct
38 Correct 115 ms 12024 KB Output is correct
39 Correct 87 ms 12024 KB Output is correct
40 Correct 3 ms 12024 KB Output is correct
41 Correct 46 ms 12024 KB Output is correct
42 Correct 95 ms 12024 KB Output is correct
43 Correct 11 ms 12024 KB Output is correct
44 Correct 60 ms 12024 KB Output is correct
45 Correct 80 ms 12024 KB Output is correct
46 Correct 101 ms 12024 KB Output is correct
47 Correct 39 ms 12024 KB Output is correct
48 Correct 5 ms 12024 KB Output is correct
49 Correct 185 ms 15836 KB Output is correct
50 Correct 149 ms 18324 KB Output is correct
51 Correct 157 ms 20120 KB Output is correct
52 Correct 142 ms 20396 KB Output is correct
53 Correct 146 ms 20476 KB Output is correct
54 Correct 195 ms 20520 KB Output is correct
55 Correct 129 ms 20684 KB Output is correct
56 Correct 142 ms 20740 KB Output is correct
57 Correct 129 ms 20740 KB Output is correct
58 Correct 392 ms 20740 KB Output is correct
59 Correct 430 ms 20740 KB Output is correct
60 Correct 423 ms 20740 KB Output is correct
61 Correct 420 ms 20868 KB Output is correct
62 Correct 402 ms 20868 KB Output is correct
63 Correct 443 ms 22924 KB Output is correct
64 Correct 392 ms 24872 KB Output is correct
65 Correct 2 ms 24872 KB Output is correct
66 Correct 2 ms 24872 KB Output is correct
67 Correct 437 ms 27176 KB Output is correct
68 Correct 448 ms 29528 KB Output is correct
69 Correct 407 ms 31288 KB Output is correct
70 Correct 380 ms 33544 KB Output is correct
71 Correct 413 ms 35800 KB Output is correct
72 Correct 392 ms 37804 KB Output is correct
73 Correct 435 ms 39784 KB Output is correct
74 Correct 423 ms 42140 KB Output is correct
75 Correct 388 ms 44216 KB Output is correct
76 Correct 451 ms 46480 KB Output is correct
77 Correct 192 ms 49292 KB Output is correct
78 Correct 137 ms 51188 KB Output is correct
79 Correct 157 ms 53052 KB Output is correct
80 Correct 163 ms 55324 KB Output is correct
81 Correct 146 ms 57308 KB Output is correct
82 Correct 156 ms 59516 KB Output is correct
83 Correct 141 ms 61560 KB Output is correct
84 Correct 324 ms 64164 KB Output is correct
85 Correct 459 ms 66236 KB Output is correct
86 Correct 142 ms 66236 KB Output is correct
87 Correct 141 ms 66236 KB Output is correct
88 Correct 473 ms 68544 KB Output is correct
89 Correct 195 ms 68544 KB Output is correct
90 Correct 143 ms 68544 KB Output is correct