Submission #47425

# Submission time Handle Problem Language Result Execution time Memory
47425 2018-05-02T18:22:08 Z tincamatei Chessboard (IZhO18_chessboard) C++14
70 / 100
140 ms 2224 KB
#include <cstdio>

const int MAX_N = 100000;
int x1[MAX_N], y1[MAX_N], x2[MAX_N], y2[MAX_N];

int main() {
  int n, k;
  long long mismatch, best = 10000000000LL;
  scanf("%d%d", &n, &k);
  for(int i = 0; i < k; ++i) {
    scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
    x1[i]--;y1[i]--;
    x2[i]--;y2[i]--;
  }
  for(int lat = 1; lat < n; ++lat)
    if(n % lat == 0) { 
      mismatch = 0;
      for(int i = 0; i < k; ++i)
        if((x1[i]/lat + y1[i]/lat) % 2 == 0)
          ++mismatch;
      mismatch = mismatch * 2 - k;
      if(mismatch + (long long)n * n / lat / lat / 2 * lat * lat < best)
        best = mismatch + (long long)n * n / lat / lat / 2 * lat * lat;
      mismatch = -mismatch;
      if(mismatch + ((long long)n * n / lat / lat + 1) / 2 * lat * lat < best)
        best = mismatch + ((long long)n * n / lat / lat + 1) / 2 * lat * lat;
    }
  printf("%lld", best);
  return 0;
}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~
chessboard.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 360 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1408 KB Output is correct
2 Correct 12 ms 1408 KB Output is correct
3 Correct 24 ms 1408 KB Output is correct
4 Correct 22 ms 1408 KB Output is correct
5 Correct 29 ms 1408 KB Output is correct
6 Correct 19 ms 1408 KB Output is correct
7 Correct 7 ms 1408 KB Output is correct
8 Correct 19 ms 1408 KB Output is correct
9 Correct 46 ms 1892 KB Output is correct
10 Correct 48 ms 1892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1892 KB Output is correct
2 Correct 2 ms 1892 KB Output is correct
3 Correct 2 ms 1892 KB Output is correct
4 Correct 2 ms 1892 KB Output is correct
5 Correct 2 ms 1892 KB Output is correct
6 Correct 2 ms 1892 KB Output is correct
7 Correct 2 ms 1892 KB Output is correct
8 Correct 2 ms 1892 KB Output is correct
9 Correct 2 ms 1892 KB Output is correct
10 Correct 2 ms 1892 KB Output is correct
11 Correct 2 ms 1892 KB Output is correct
12 Correct 2 ms 1892 KB Output is correct
13 Correct 2 ms 1892 KB Output is correct
14 Correct 2 ms 1892 KB Output is correct
15 Correct 2 ms 1892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1892 KB Output is correct
2 Correct 2 ms 1892 KB Output is correct
3 Correct 2 ms 1892 KB Output is correct
4 Correct 2 ms 1892 KB Output is correct
5 Correct 2 ms 1892 KB Output is correct
6 Correct 2 ms 1892 KB Output is correct
7 Correct 2 ms 1892 KB Output is correct
8 Correct 2 ms 1892 KB Output is correct
9 Correct 2 ms 1892 KB Output is correct
10 Correct 2 ms 1892 KB Output is correct
11 Correct 2 ms 1892 KB Output is correct
12 Correct 2 ms 1892 KB Output is correct
13 Correct 2 ms 1892 KB Output is correct
14 Correct 2 ms 1892 KB Output is correct
15 Correct 2 ms 1892 KB Output is correct
16 Correct 14 ms 1892 KB Output is correct
17 Correct 39 ms 1892 KB Output is correct
18 Correct 44 ms 2148 KB Output is correct
19 Correct 55 ms 2148 KB Output is correct
20 Correct 60 ms 2156 KB Output is correct
21 Correct 34 ms 2156 KB Output is correct
22 Correct 2 ms 2156 KB Output is correct
23 Correct 20 ms 2156 KB Output is correct
24 Correct 40 ms 2156 KB Output is correct
25 Correct 6 ms 2156 KB Output is correct
26 Correct 26 ms 2156 KB Output is correct
27 Correct 32 ms 2156 KB Output is correct
28 Correct 42 ms 2156 KB Output is correct
29 Correct 16 ms 2156 KB Output is correct
30 Correct 3 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1408 KB Output is correct
2 Correct 12 ms 1408 KB Output is correct
3 Correct 24 ms 1408 KB Output is correct
4 Correct 22 ms 1408 KB Output is correct
5 Correct 29 ms 1408 KB Output is correct
6 Correct 19 ms 1408 KB Output is correct
7 Correct 7 ms 1408 KB Output is correct
8 Correct 19 ms 1408 KB Output is correct
9 Correct 46 ms 1892 KB Output is correct
10 Correct 48 ms 1892 KB Output is correct
11 Correct 2 ms 1892 KB Output is correct
12 Correct 2 ms 1892 KB Output is correct
13 Correct 2 ms 1892 KB Output is correct
14 Correct 2 ms 1892 KB Output is correct
15 Correct 2 ms 1892 KB Output is correct
16 Correct 2 ms 1892 KB Output is correct
17 Correct 2 ms 1892 KB Output is correct
18 Correct 2 ms 1892 KB Output is correct
19 Correct 2 ms 1892 KB Output is correct
20 Correct 2 ms 1892 KB Output is correct
21 Correct 2 ms 1892 KB Output is correct
22 Correct 2 ms 1892 KB Output is correct
23 Correct 2 ms 1892 KB Output is correct
24 Correct 2 ms 1892 KB Output is correct
25 Correct 2 ms 1892 KB Output is correct
26 Correct 14 ms 1892 KB Output is correct
27 Correct 39 ms 1892 KB Output is correct
28 Correct 44 ms 2148 KB Output is correct
29 Correct 55 ms 2148 KB Output is correct
30 Correct 60 ms 2156 KB Output is correct
31 Correct 34 ms 2156 KB Output is correct
32 Correct 2 ms 2156 KB Output is correct
33 Correct 20 ms 2156 KB Output is correct
34 Correct 40 ms 2156 KB Output is correct
35 Correct 6 ms 2156 KB Output is correct
36 Correct 26 ms 2156 KB Output is correct
37 Correct 32 ms 2156 KB Output is correct
38 Correct 42 ms 2156 KB Output is correct
39 Correct 16 ms 2156 KB Output is correct
40 Correct 3 ms 2156 KB Output is correct
41 Correct 59 ms 2156 KB Output is correct
42 Correct 53 ms 2156 KB Output is correct
43 Correct 68 ms 2156 KB Output is correct
44 Correct 58 ms 2156 KB Output is correct
45 Correct 66 ms 2156 KB Output is correct
46 Correct 65 ms 2156 KB Output is correct
47 Correct 46 ms 2156 KB Output is correct
48 Correct 50 ms 2156 KB Output is correct
49 Correct 46 ms 2156 KB Output is correct
50 Correct 125 ms 2156 KB Output is correct
51 Correct 135 ms 2156 KB Output is correct
52 Correct 125 ms 2156 KB Output is correct
53 Correct 134 ms 2156 KB Output is correct
54 Correct 123 ms 2156 KB Output is correct
55 Correct 140 ms 2224 KB Output is correct
56 Correct 120 ms 2224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 360 KB Output is correct
4 Correct 2 ms 428 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 33 ms 1408 KB Output is correct
10 Correct 12 ms 1408 KB Output is correct
11 Correct 24 ms 1408 KB Output is correct
12 Correct 22 ms 1408 KB Output is correct
13 Correct 29 ms 1408 KB Output is correct
14 Correct 19 ms 1408 KB Output is correct
15 Correct 7 ms 1408 KB Output is correct
16 Correct 19 ms 1408 KB Output is correct
17 Correct 46 ms 1892 KB Output is correct
18 Correct 48 ms 1892 KB Output is correct
19 Correct 2 ms 1892 KB Output is correct
20 Correct 2 ms 1892 KB Output is correct
21 Correct 2 ms 1892 KB Output is correct
22 Correct 2 ms 1892 KB Output is correct
23 Correct 2 ms 1892 KB Output is correct
24 Correct 2 ms 1892 KB Output is correct
25 Correct 2 ms 1892 KB Output is correct
26 Correct 2 ms 1892 KB Output is correct
27 Correct 2 ms 1892 KB Output is correct
28 Correct 2 ms 1892 KB Output is correct
29 Correct 2 ms 1892 KB Output is correct
30 Correct 2 ms 1892 KB Output is correct
31 Correct 2 ms 1892 KB Output is correct
32 Correct 2 ms 1892 KB Output is correct
33 Correct 2 ms 1892 KB Output is correct
34 Correct 14 ms 1892 KB Output is correct
35 Correct 39 ms 1892 KB Output is correct
36 Correct 44 ms 2148 KB Output is correct
37 Correct 55 ms 2148 KB Output is correct
38 Correct 60 ms 2156 KB Output is correct
39 Correct 34 ms 2156 KB Output is correct
40 Correct 2 ms 2156 KB Output is correct
41 Correct 20 ms 2156 KB Output is correct
42 Correct 40 ms 2156 KB Output is correct
43 Correct 6 ms 2156 KB Output is correct
44 Correct 26 ms 2156 KB Output is correct
45 Correct 32 ms 2156 KB Output is correct
46 Correct 42 ms 2156 KB Output is correct
47 Correct 16 ms 2156 KB Output is correct
48 Correct 3 ms 2156 KB Output is correct
49 Correct 59 ms 2156 KB Output is correct
50 Correct 53 ms 2156 KB Output is correct
51 Correct 68 ms 2156 KB Output is correct
52 Correct 58 ms 2156 KB Output is correct
53 Correct 66 ms 2156 KB Output is correct
54 Correct 65 ms 2156 KB Output is correct
55 Correct 46 ms 2156 KB Output is correct
56 Correct 50 ms 2156 KB Output is correct
57 Correct 46 ms 2156 KB Output is correct
58 Correct 125 ms 2156 KB Output is correct
59 Correct 135 ms 2156 KB Output is correct
60 Correct 125 ms 2156 KB Output is correct
61 Correct 134 ms 2156 KB Output is correct
62 Correct 123 ms 2156 KB Output is correct
63 Correct 140 ms 2224 KB Output is correct
64 Correct 120 ms 2224 KB Output is correct
65 Correct 2 ms 2224 KB Output is correct
66 Incorrect 2 ms 2224 KB Output isn't correct
67 Halted 0 ms 0 KB -