# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334354 | 2020-12-09T04:15:34 Z | beksultan04 | Chessboard (IZhO18_chessboard) | C++14 | 903 ms | 4972 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define pb push_back #define endi puts(""); const int N = 1e5+12,INF=1e9+7; int resh[N],ans[N],n; vector <int> v[N]; int fun(int x){ int i,j,ans=0,cnt=0,res=0,c=1; for (i=0;i<n;++i){ if (i % x == 0 && i != 0){ c++; } if (c%2 ){ res += (((n/x)+1)/2)*x; } else { res += ((((n-x)/x)+1)/2)*x; } } c=1; for (i=1;i<=n;++i){ for (j=0;j<v[i].size();++j){ int y = (v[i][j]-1)/x; if (y%2 == 0 && c%2 == 1 || y%2 == 1 && c%2 == 0 )res--; else res++; } if (i % x == 0) c++; } ret (res); } int fun1(int x){ int i,j,ans=0,cnt=0,res=0,c=0; for (i=0;i<n;++i){ if (i % x == 0 && i != 0){ c++; } if (c%2 ){ res += (((n/x)+1)/2)*x; } else { res += ((((n-x)/x)+1)/2)*x; } } c=0; for (i=1;i<=n;++i){ for (j=0;j<v[i].size();++j){ int y = (v[i][j]-1)/x; if (y%2 == 0 && c%2 == 1 || y%2 == 1 && c%2 == 0 )res--; else res++; } if (i % x == 0) c++; } ret (res); } main(){ int k,i,j; vector <int> pr; scan2(n,k) while (k--){ int x1,x2,y1,y2; scan2(x1,y1) scan2(x2,y2) v[x1].pb(y1); } /// /////////////////////// for (i=2;i*i<=n;++i){ if (n%i==0){ pr.pb(i); if (i*i != n)pr.pb(n/i); } } int ans=min(fun(1),fun1(1)); for (i=0;i<pr.size();++i){ ans = min(ans,min(fun(pr[i]),fun1(pr[i]))); } cout <<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 3948 KB | Output is correct |
2 | Correct | 11 ms | 3052 KB | Output is correct |
3 | Correct | 30 ms | 3820 KB | Output is correct |
4 | Correct | 23 ms | 3436 KB | Output is correct |
5 | Correct | 44 ms | 3968 KB | Output is correct |
6 | Correct | 25 ms | 3564 KB | Output is correct |
7 | Correct | 7 ms | 3052 KB | Output is correct |
8 | Correct | 25 ms | 3564 KB | Output is correct |
9 | Correct | 52 ms | 4332 KB | Output is correct |
10 | Correct | 34 ms | 3816 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
4 | Correct | 3 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2688 KB | Output is correct |
11 | Correct | 2 ms | 2668 KB | Output is correct |
12 | Correct | 2 ms | 2668 KB | Output is correct |
13 | Correct | 3 ms | 2668 KB | Output is correct |
14 | Correct | 3 ms | 2668 KB | Output is correct |
15 | Correct | 2 ms | 2668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
4 | Correct | 3 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 2 ms | 2668 KB | Output is correct |
10 | Correct | 2 ms | 2688 KB | Output is correct |
11 | Correct | 2 ms | 2668 KB | Output is correct |
12 | Correct | 2 ms | 2668 KB | Output is correct |
13 | Correct | 3 ms | 2668 KB | Output is correct |
14 | Correct | 3 ms | 2668 KB | Output is correct |
15 | Correct | 2 ms | 2668 KB | Output is correct |
16 | Correct | 15 ms | 3072 KB | Output is correct |
17 | Correct | 37 ms | 3820 KB | Output is correct |
18 | Correct | 45 ms | 3820 KB | Output is correct |
19 | Correct | 85 ms | 3820 KB | Output is correct |
20 | Correct | 94 ms | 3820 KB | Output is correct |
21 | Correct | 34 ms | 3820 KB | Output is correct |
22 | Correct | 3 ms | 2668 KB | Output is correct |
23 | Correct | 25 ms | 3200 KB | Output is correct |
24 | Correct | 43 ms | 3820 KB | Output is correct |
25 | Correct | 7 ms | 2796 KB | Output is correct |
26 | Correct | 27 ms | 3436 KB | Output is correct |
27 | Correct | 35 ms | 3692 KB | Output is correct |
28 | Correct | 43 ms | 3820 KB | Output is correct |
29 | Correct | 16 ms | 3180 KB | Output is correct |
30 | Correct | 4 ms | 2668 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 3948 KB | Output is correct |
2 | Correct | 11 ms | 3052 KB | Output is correct |
3 | Correct | 30 ms | 3820 KB | Output is correct |
4 | Correct | 23 ms | 3436 KB | Output is correct |
5 | Correct | 44 ms | 3968 KB | Output is correct |
6 | Correct | 25 ms | 3564 KB | Output is correct |
7 | Correct | 7 ms | 3052 KB | Output is correct |
8 | Correct | 25 ms | 3564 KB | Output is correct |
9 | Correct | 52 ms | 4332 KB | Output is correct |
10 | Correct | 34 ms | 3816 KB | Output is correct |
11 | Correct | 2 ms | 2668 KB | Output is correct |
12 | Correct | 2 ms | 2668 KB | Output is correct |
13 | Correct | 2 ms | 2668 KB | Output is correct |
14 | Correct | 3 ms | 2668 KB | Output is correct |
15 | Correct | 2 ms | 2668 KB | Output is correct |
16 | Correct | 2 ms | 2668 KB | Output is correct |
17 | Correct | 2 ms | 2668 KB | Output is correct |
18 | Correct | 2 ms | 2668 KB | Output is correct |
19 | Correct | 2 ms | 2668 KB | Output is correct |
20 | Correct | 2 ms | 2688 KB | Output is correct |
21 | Correct | 2 ms | 2668 KB | Output is correct |
22 | Correct | 2 ms | 2668 KB | Output is correct |
23 | Correct | 3 ms | 2668 KB | Output is correct |
24 | Correct | 3 ms | 2668 KB | Output is correct |
25 | Correct | 2 ms | 2668 KB | Output is correct |
26 | Correct | 15 ms | 3072 KB | Output is correct |
27 | Correct | 37 ms | 3820 KB | Output is correct |
28 | Correct | 45 ms | 3820 KB | Output is correct |
29 | Correct | 85 ms | 3820 KB | Output is correct |
30 | Correct | 94 ms | 3820 KB | Output is correct |
31 | Correct | 34 ms | 3820 KB | Output is correct |
32 | Correct | 3 ms | 2668 KB | Output is correct |
33 | Correct | 25 ms | 3200 KB | Output is correct |
34 | Correct | 43 ms | 3820 KB | Output is correct |
35 | Correct | 7 ms | 2796 KB | Output is correct |
36 | Correct | 27 ms | 3436 KB | Output is correct |
37 | Correct | 35 ms | 3692 KB | Output is correct |
38 | Correct | 43 ms | 3820 KB | Output is correct |
39 | Correct | 16 ms | 3180 KB | Output is correct |
40 | Correct | 4 ms | 2668 KB | Output is correct |
41 | Correct | 213 ms | 4700 KB | Output is correct |
42 | Correct | 82 ms | 4844 KB | Output is correct |
43 | Correct | 128 ms | 4588 KB | Output is correct |
44 | Correct | 76 ms | 4716 KB | Output is correct |
45 | Correct | 70 ms | 4972 KB | Output is correct |
46 | Correct | 228 ms | 4856 KB | Output is correct |
47 | Correct | 59 ms | 4716 KB | Output is correct |
48 | Correct | 109 ms | 4844 KB | Output is correct |
49 | Correct | 69 ms | 4716 KB | Output is correct |
50 | Correct | 887 ms | 4716 KB | Output is correct |
51 | Correct | 887 ms | 4844 KB | Output is correct |
52 | Correct | 877 ms | 4716 KB | Output is correct |
53 | Correct | 878 ms | 4844 KB | Output is correct |
54 | Correct | 860 ms | 4716 KB | Output is correct |
55 | Correct | 903 ms | 4972 KB | Output is correct |
56 | Correct | 853 ms | 4844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | Output is correct |
2 | Correct | 2 ms | 2668 KB | Output is correct |
3 | Correct | 2 ms | 2668 KB | Output is correct |
4 | Correct | 2 ms | 2668 KB | Output is correct |
5 | Correct | 2 ms | 2668 KB | Output is correct |
6 | Correct | 2 ms | 2668 KB | Output is correct |
7 | Correct | 2 ms | 2668 KB | Output is correct |
8 | Correct | 2 ms | 2668 KB | Output is correct |
9 | Correct | 40 ms | 3948 KB | Output is correct |
10 | Correct | 11 ms | 3052 KB | Output is correct |
11 | Correct | 30 ms | 3820 KB | Output is correct |
12 | Correct | 23 ms | 3436 KB | Output is correct |
13 | Correct | 44 ms | 3968 KB | Output is correct |
14 | Correct | 25 ms | 3564 KB | Output is correct |
15 | Correct | 7 ms | 3052 KB | Output is correct |
16 | Correct | 25 ms | 3564 KB | Output is correct |
17 | Correct | 52 ms | 4332 KB | Output is correct |
18 | Correct | 34 ms | 3816 KB | Output is correct |
19 | Correct | 2 ms | 2668 KB | Output is correct |
20 | Correct | 2 ms | 2668 KB | Output is correct |
21 | Correct | 2 ms | 2668 KB | Output is correct |
22 | Correct | 3 ms | 2668 KB | Output is correct |
23 | Correct | 2 ms | 2668 KB | Output is correct |
24 | Correct | 2 ms | 2668 KB | Output is correct |
25 | Correct | 2 ms | 2668 KB | Output is correct |
26 | Correct | 2 ms | 2668 KB | Output is correct |
27 | Correct | 2 ms | 2668 KB | Output is correct |
28 | Correct | 2 ms | 2688 KB | Output is correct |
29 | Correct | 2 ms | 2668 KB | Output is correct |
30 | Correct | 2 ms | 2668 KB | Output is correct |
31 | Correct | 3 ms | 2668 KB | Output is correct |
32 | Correct | 3 ms | 2668 KB | Output is correct |
33 | Correct | 2 ms | 2668 KB | Output is correct |
34 | Correct | 15 ms | 3072 KB | Output is correct |
35 | Correct | 37 ms | 3820 KB | Output is correct |
36 | Correct | 45 ms | 3820 KB | Output is correct |
37 | Correct | 85 ms | 3820 KB | Output is correct |
38 | Correct | 94 ms | 3820 KB | Output is correct |
39 | Correct | 34 ms | 3820 KB | Output is correct |
40 | Correct | 3 ms | 2668 KB | Output is correct |
41 | Correct | 25 ms | 3200 KB | Output is correct |
42 | Correct | 43 ms | 3820 KB | Output is correct |
43 | Correct | 7 ms | 2796 KB | Output is correct |
44 | Correct | 27 ms | 3436 KB | Output is correct |
45 | Correct | 35 ms | 3692 KB | Output is correct |
46 | Correct | 43 ms | 3820 KB | Output is correct |
47 | Correct | 16 ms | 3180 KB | Output is correct |
48 | Correct | 4 ms | 2668 KB | Output is correct |
49 | Correct | 213 ms | 4700 KB | Output is correct |
50 | Correct | 82 ms | 4844 KB | Output is correct |
51 | Correct | 128 ms | 4588 KB | Output is correct |
52 | Correct | 76 ms | 4716 KB | Output is correct |
53 | Correct | 70 ms | 4972 KB | Output is correct |
54 | Correct | 228 ms | 4856 KB | Output is correct |
55 | Correct | 59 ms | 4716 KB | Output is correct |
56 | Correct | 109 ms | 4844 KB | Output is correct |
57 | Correct | 69 ms | 4716 KB | Output is correct |
58 | Correct | 887 ms | 4716 KB | Output is correct |
59 | Correct | 887 ms | 4844 KB | Output is correct |
60 | Correct | 877 ms | 4716 KB | Output is correct |
61 | Correct | 878 ms | 4844 KB | Output is correct |
62 | Correct | 860 ms | 4716 KB | Output is correct |
63 | Correct | 903 ms | 4972 KB | Output is correct |
64 | Correct | 853 ms | 4844 KB | Output is correct |
65 | Correct | 2 ms | 2668 KB | Output is correct |
66 | Incorrect | 2 ms | 2668 KB | Output isn't correct |
67 | Halted | 0 ms | 0 KB | - |