Submission #168429

# Submission time Handle Problem Language Result Execution time Memory
168429 2019-12-13T05:00:10 Z juggernaut Chessboard (IZhO18_chessboard) C++14
70 / 100
411 ms 4344 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 cnt=0,c[2];
    c[0]=c[1]=0;
    for(int i=0;i<k;i++){
        c[(p[i].fr/f+p[i].sc/f)%2]++;
    }
    int m=n/f;
    int res=f*f*((m/2)*m+((m%2)*(m/2)))-c[1]+c[0];
    res=min(res,f*f*((m/2)*m+((m%2)*((m+1)/2)))-c[0]+c[1]);
    return res;
}
/*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

chessboard.cpp: In function 'long long int get(long long int)':
chessboard.cpp:10:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt=0,c[2];
         ^~~
chessboard.cpp: At global scope:
chessboard.cpp:34:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
chessboard.cpp: In function 'int main()':
chessboard.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~
chessboard.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld%lld",&p[i].fr,&p[i].sc,&p[i].fr,&p[i].sc);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 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 256 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
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1272 KB Output is correct
2 Correct 10 ms 604 KB Output is correct
3 Correct 22 ms 988 KB Output is correct
4 Correct 23 ms 1016 KB Output is correct
5 Correct 29 ms 1144 KB Output is correct
6 Correct 19 ms 888 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 19 ms 888 KB Output is correct
9 Correct 46 ms 1784 KB Output is correct
10 Correct 27 ms 1144 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 3 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 380 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 3 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 380 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 38 ms 1784 KB Output is correct
18 Correct 49 ms 2040 KB Output is correct
19 Correct 105 ms 1916 KB Output is correct
20 Correct 117 ms 2140 KB Output is correct
21 Correct 37 ms 1784 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 27 ms 1144 KB Output is correct
24 Correct 46 ms 1912 KB Output is correct
25 Correct 8 ms 508 KB Output is correct
26 Correct 30 ms 1272 KB Output is correct
27 Correct 39 ms 1528 KB Output is correct
28 Correct 48 ms 1912 KB Output is correct
29 Correct 16 ms 1016 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1272 KB Output is correct
2 Correct 10 ms 604 KB Output is correct
3 Correct 22 ms 988 KB Output is correct
4 Correct 23 ms 1016 KB Output is correct
5 Correct 29 ms 1144 KB Output is correct
6 Correct 19 ms 888 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 19 ms 888 KB Output is correct
9 Correct 46 ms 1784 KB Output is correct
10 Correct 27 ms 1144 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 3 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 380 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 38 ms 1784 KB Output is correct
28 Correct 49 ms 2040 KB Output is correct
29 Correct 105 ms 1916 KB Output is correct
30 Correct 117 ms 2140 KB Output is correct
31 Correct 37 ms 1784 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
33 Correct 27 ms 1144 KB Output is correct
34 Correct 46 ms 1912 KB Output is correct
35 Correct 8 ms 508 KB Output is correct
36 Correct 30 ms 1272 KB Output is correct
37 Correct 39 ms 1528 KB Output is correct
38 Correct 48 ms 1912 KB Output is correct
39 Correct 16 ms 1016 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 96 ms 1880 KB Output is correct
42 Correct 55 ms 4088 KB Output is correct
43 Correct 68 ms 3704 KB Output is correct
44 Correct 53 ms 3960 KB Output is correct
45 Correct 52 ms 4120 KB Output is correct
46 Correct 107 ms 4088 KB Output is correct
47 Correct 45 ms 3704 KB Output is correct
48 Correct 61 ms 3704 KB Output is correct
49 Correct 49 ms 3576 KB Output is correct
50 Correct 374 ms 3960 KB Output is correct
51 Correct 400 ms 4216 KB Output is correct
52 Correct 371 ms 3832 KB Output is correct
53 Correct 396 ms 4220 KB Output is correct
54 Correct 366 ms 3832 KB Output is correct
55 Correct 411 ms 4344 KB Output is correct
56 Correct 356 ms 3832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 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 256 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 33 ms 1272 KB Output is correct
10 Correct 10 ms 604 KB Output is correct
11 Correct 22 ms 988 KB Output is correct
12 Correct 23 ms 1016 KB Output is correct
13 Correct 29 ms 1144 KB Output is correct
14 Correct 19 ms 888 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 19 ms 888 KB Output is correct
17 Correct 46 ms 1784 KB Output is correct
18 Correct 27 ms 1144 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 3 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 380 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 38 ms 1784 KB Output is correct
36 Correct 49 ms 2040 KB Output is correct
37 Correct 105 ms 1916 KB Output is correct
38 Correct 117 ms 2140 KB Output is correct
39 Correct 37 ms 1784 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 27 ms 1144 KB Output is correct
42 Correct 46 ms 1912 KB Output is correct
43 Correct 8 ms 508 KB Output is correct
44 Correct 30 ms 1272 KB Output is correct
45 Correct 39 ms 1528 KB Output is correct
46 Correct 48 ms 1912 KB Output is correct
47 Correct 16 ms 1016 KB Output is correct
48 Correct 3 ms 376 KB Output is correct
49 Correct 96 ms 1880 KB Output is correct
50 Correct 55 ms 4088 KB Output is correct
51 Correct 68 ms 3704 KB Output is correct
52 Correct 53 ms 3960 KB Output is correct
53 Correct 52 ms 4120 KB Output is correct
54 Correct 107 ms 4088 KB Output is correct
55 Correct 45 ms 3704 KB Output is correct
56 Correct 61 ms 3704 KB Output is correct
57 Correct 49 ms 3576 KB Output is correct
58 Correct 374 ms 3960 KB Output is correct
59 Correct 400 ms 4216 KB Output is correct
60 Correct 371 ms 3832 KB Output is correct
61 Correct 396 ms 4220 KB Output is correct
62 Correct 366 ms 3832 KB Output is correct
63 Correct 411 ms 4344 KB Output is correct
64 Correct 356 ms 3832 KB Output is correct
65 Correct 2 ms 376 KB Output is correct
66 Incorrect 2 ms 376 KB Output isn't correct
67 Halted 0 ms 0 KB -