# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168426 | 2019-12-13T04:40:37 Z | juggernaut | Chessboard (IZhO18_chessboard) | C++14 | 661 ms | 3836 KB |
#include<bits/stdc++.h> #define int long long int #define fr first #define sc second using namespace std; int n,k,i,j,x,y,res; pair<int,int>p[100001]; bool a[1001][1001]; int get(int f,int q){ int cnt=0; for(int i=0;i<n;i++) for(int j=0;j<n;j++){ x=i/f; y=j/f; if(q){ if((x+y)%2==0){ if(a[i][j])cnt++; }else{ if(!a[i][j])cnt++; } }else{ if((x+y)%2==0){ if(!a[i][j])cnt++; }else{ if(a[i][j])cnt++; } } } return cnt; } int get(int f){ return min(get(f,0),get(f,1)); } void subtask2(){ int c[2]; c[0]=c[1]=0; for(i=0;i<k;i++){ scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc); p[i].fr--; p[i].sc--; c[(p[i].fr+p[i].sc)%2]++; } res=(n/2)*n+((n%2)*(n/2))-c[1]+c[0]; res=min(res,(n/2)*n+((n%2)*((n+1)/2))-c[0]+c[1]); printf("%lld",res); exit(0); } main(){ scanf("%lld%lld",&n,&k); if(n>1000)subtask2(); for(i=0;i<k;i++){ scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc); p[i].fr--; p[i].sc--; a[p[i].fr][p[i].sc]=1; } res=get(1); for(j=2;j*j<=n;j++){ if(n%j==0){ res=min(res,get(j)); res=min(res,get(n/j)); } } printf("%lld",res); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 4 ms | 256 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 2808 KB | Output is correct |
2 | Correct | 9 ms | 888 KB | Output is correct |
3 | Correct | 22 ms | 1912 KB | Output is correct |
4 | Correct | 22 ms | 1912 KB | Output is correct |
5 | Correct | 28 ms | 2552 KB | Output is correct |
6 | Correct | 18 ms | 1676 KB | Output is correct |
7 | Correct | 5 ms | 632 KB | Output is correct |
8 | Correct | 18 ms | 1788 KB | Output is correct |
9 | Correct | 45 ms | 3836 KB | Output is correct |
10 | Correct | 26 ms | 2296 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 380 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 504 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 380 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 | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 380 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 504 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 380 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 | 3 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 81 ms | 1760 KB | Output is correct |
17 | Correct | 63 ms | 2652 KB | Output is correct |
18 | Correct | 119 ms | 2784 KB | Output is correct |
19 | Correct | 657 ms | 2724 KB | Output is correct |
20 | Correct | 661 ms | 2808 KB | Output is correct |
21 | Correct | 62 ms | 2552 KB | Output is correct |
22 | Correct | 376 ms | 1244 KB | Output is correct |
23 | Correct | 183 ms | 1912 KB | Output is correct |
24 | Correct | 119 ms | 2732 KB | Output is correct |
25 | Correct | 173 ms | 1400 KB | Output is correct |
26 | Correct | 95 ms | 2300 KB | Output is correct |
27 | Correct | 146 ms | 2372 KB | Output is correct |
28 | Correct | 111 ms | 2680 KB | Output is correct |
29 | Correct | 41 ms | 1788 KB | Output is correct |
30 | Correct | 76 ms | 1372 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 2808 KB | Output is correct |
2 | Correct | 9 ms | 888 KB | Output is correct |
3 | Correct | 22 ms | 1912 KB | Output is correct |
4 | Correct | 22 ms | 1912 KB | Output is correct |
5 | Correct | 28 ms | 2552 KB | Output is correct |
6 | Correct | 18 ms | 1676 KB | Output is correct |
7 | Correct | 5 ms | 632 KB | Output is correct |
8 | Correct | 18 ms | 1788 KB | Output is correct |
9 | Correct | 45 ms | 3836 KB | Output is correct |
10 | Correct | 26 ms | 2296 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
12 | Correct | 3 ms | 380 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 3 ms | 376 KB | Output is correct |
15 | Correct | 3 ms | 376 KB | Output is correct |
16 | Correct | 3 ms | 376 KB | Output is correct |
17 | Correct | 3 ms | 504 KB | Output is correct |
18 | Correct | 3 ms | 376 KB | Output is correct |
19 | Correct | 3 ms | 380 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 | 3 ms | 376 KB | Output is correct |
24 | Correct | 3 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 81 ms | 1760 KB | Output is correct |
27 | Correct | 63 ms | 2652 KB | Output is correct |
28 | Correct | 119 ms | 2784 KB | Output is correct |
29 | Correct | 657 ms | 2724 KB | Output is correct |
30 | Correct | 661 ms | 2808 KB | Output is correct |
31 | Correct | 62 ms | 2552 KB | Output is correct |
32 | Correct | 376 ms | 1244 KB | Output is correct |
33 | Correct | 183 ms | 1912 KB | Output is correct |
34 | Correct | 119 ms | 2732 KB | Output is correct |
35 | Correct | 173 ms | 1400 KB | Output is correct |
36 | Correct | 95 ms | 2300 KB | Output is correct |
37 | Correct | 146 ms | 2372 KB | Output is correct |
38 | Correct | 111 ms | 2680 KB | Output is correct |
39 | Correct | 41 ms | 1788 KB | Output is correct |
40 | Correct | 76 ms | 1372 KB | Output is correct |
41 | Incorrect | 42 ms | 3536 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 4 ms | 256 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 256 KB | Output is correct |
9 | Correct | 31 ms | 2808 KB | Output is correct |
10 | Correct | 9 ms | 888 KB | Output is correct |
11 | Correct | 22 ms | 1912 KB | Output is correct |
12 | Correct | 22 ms | 1912 KB | Output is correct |
13 | Correct | 28 ms | 2552 KB | Output is correct |
14 | Correct | 18 ms | 1676 KB | Output is correct |
15 | Correct | 5 ms | 632 KB | Output is correct |
16 | Correct | 18 ms | 1788 KB | Output is correct |
17 | Correct | 45 ms | 3836 KB | Output is correct |
18 | Correct | 26 ms | 2296 KB | Output is correct |
19 | Correct | 3 ms | 376 KB | Output is correct |
20 | Correct | 3 ms | 380 KB | Output is correct |
21 | Correct | 4 ms | 376 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 3 ms | 376 KB | Output is correct |
24 | Correct | 3 ms | 376 KB | Output is correct |
25 | Correct | 3 ms | 504 KB | Output is correct |
26 | Correct | 3 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 380 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 | 3 ms | 376 KB | Output is correct |
32 | Correct | 3 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 81 ms | 1760 KB | Output is correct |
35 | Correct | 63 ms | 2652 KB | Output is correct |
36 | Correct | 119 ms | 2784 KB | Output is correct |
37 | Correct | 657 ms | 2724 KB | Output is correct |
38 | Correct | 661 ms | 2808 KB | Output is correct |
39 | Correct | 62 ms | 2552 KB | Output is correct |
40 | Correct | 376 ms | 1244 KB | Output is correct |
41 | Correct | 183 ms | 1912 KB | Output is correct |
42 | Correct | 119 ms | 2732 KB | Output is correct |
43 | Correct | 173 ms | 1400 KB | Output is correct |
44 | Correct | 95 ms | 2300 KB | Output is correct |
45 | Correct | 146 ms | 2372 KB | Output is correct |
46 | Correct | 111 ms | 2680 KB | Output is correct |
47 | Correct | 41 ms | 1788 KB | Output is correct |
48 | Correct | 76 ms | 1372 KB | Output is correct |
49 | Incorrect | 42 ms | 3536 KB | Output isn't correct |
50 | Halted | 0 ms | 0 KB | - |