Submission #47424

# Submission time Handle Problem Language Result Execution time Memory
47424 2018-05-02T17:49:20 Z tincamatei Chessboard (IZhO18_chessboard) C++14
70 / 100
153 ms 61184 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;
        else
          --mismatch;
      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 248 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
8 Correct 2 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3108 KB Output is correct
2 Correct 11 ms 3108 KB Output is correct
3 Correct 23 ms 4084 KB Output is correct
4 Correct 22 ms 5072 KB Output is correct
5 Correct 29 ms 6448 KB Output is correct
6 Correct 20 ms 6972 KB Output is correct
7 Correct 6 ms 6972 KB Output is correct
8 Correct 20 ms 8020 KB Output is correct
9 Correct 47 ms 11032 KB Output is correct
10 Correct 27 ms 11556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11556 KB Output is correct
2 Correct 2 ms 11556 KB Output is correct
3 Correct 2 ms 11556 KB Output is correct
4 Correct 2 ms 11556 KB Output is correct
5 Correct 2 ms 11556 KB Output is correct
6 Correct 2 ms 11556 KB Output is correct
7 Correct 2 ms 11556 KB Output is correct
8 Correct 2 ms 11556 KB Output is correct
9 Correct 2 ms 11556 KB Output is correct
10 Correct 2 ms 11556 KB Output is correct
11 Correct 2 ms 11556 KB Output is correct
12 Correct 2 ms 11556 KB Output is correct
13 Correct 2 ms 11556 KB Output is correct
14 Correct 2 ms 11556 KB Output is correct
15 Correct 2 ms 11556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 11556 KB Output is correct
2 Correct 2 ms 11556 KB Output is correct
3 Correct 2 ms 11556 KB Output is correct
4 Correct 2 ms 11556 KB Output is correct
5 Correct 2 ms 11556 KB Output is correct
6 Correct 2 ms 11556 KB Output is correct
7 Correct 2 ms 11556 KB Output is correct
8 Correct 2 ms 11556 KB Output is correct
9 Correct 2 ms 11556 KB Output is correct
10 Correct 2 ms 11556 KB Output is correct
11 Correct 2 ms 11556 KB Output is correct
12 Correct 2 ms 11556 KB Output is correct
13 Correct 2 ms 11556 KB Output is correct
14 Correct 2 ms 11556 KB Output is correct
15 Correct 2 ms 11556 KB Output is correct
16 Correct 14 ms 11728 KB Output is correct
17 Correct 39 ms 13964 KB Output is correct
18 Correct 46 ms 15868 KB Output is correct
19 Correct 56 ms 17244 KB Output is correct
20 Correct 62 ms 18956 KB Output is correct
21 Correct 35 ms 19968 KB Output is correct
22 Correct 2 ms 19968 KB Output is correct
23 Correct 22 ms 20008 KB Output is correct
24 Correct 41 ms 22248 KB Output is correct
25 Correct 6 ms 22248 KB Output is correct
26 Correct 25 ms 22700 KB Output is correct
27 Correct 32 ms 23996 KB Output is correct
28 Correct 45 ms 25992 KB Output is correct
29 Correct 29 ms 25992 KB Output is correct
30 Correct 3 ms 25992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 3108 KB Output is correct
2 Correct 11 ms 3108 KB Output is correct
3 Correct 23 ms 4084 KB Output is correct
4 Correct 22 ms 5072 KB Output is correct
5 Correct 29 ms 6448 KB Output is correct
6 Correct 20 ms 6972 KB Output is correct
7 Correct 6 ms 6972 KB Output is correct
8 Correct 20 ms 8020 KB Output is correct
9 Correct 47 ms 11032 KB Output is correct
10 Correct 27 ms 11556 KB Output is correct
11 Correct 2 ms 11556 KB Output is correct
12 Correct 2 ms 11556 KB Output is correct
13 Correct 2 ms 11556 KB Output is correct
14 Correct 2 ms 11556 KB Output is correct
15 Correct 2 ms 11556 KB Output is correct
16 Correct 2 ms 11556 KB Output is correct
17 Correct 2 ms 11556 KB Output is correct
18 Correct 2 ms 11556 KB Output is correct
19 Correct 2 ms 11556 KB Output is correct
20 Correct 2 ms 11556 KB Output is correct
21 Correct 2 ms 11556 KB Output is correct
22 Correct 2 ms 11556 KB Output is correct
23 Correct 2 ms 11556 KB Output is correct
24 Correct 2 ms 11556 KB Output is correct
25 Correct 2 ms 11556 KB Output is correct
26 Correct 14 ms 11728 KB Output is correct
27 Correct 39 ms 13964 KB Output is correct
28 Correct 46 ms 15868 KB Output is correct
29 Correct 56 ms 17244 KB Output is correct
30 Correct 62 ms 18956 KB Output is correct
31 Correct 35 ms 19968 KB Output is correct
32 Correct 2 ms 19968 KB Output is correct
33 Correct 22 ms 20008 KB Output is correct
34 Correct 41 ms 22248 KB Output is correct
35 Correct 6 ms 22248 KB Output is correct
36 Correct 25 ms 22700 KB Output is correct
37 Correct 32 ms 23996 KB Output is correct
38 Correct 45 ms 25992 KB Output is correct
39 Correct 29 ms 25992 KB Output is correct
40 Correct 3 ms 25992 KB Output is correct
41 Correct 63 ms 28564 KB Output is correct
42 Correct 54 ms 30888 KB Output is correct
43 Correct 85 ms 32720 KB Output is correct
44 Correct 51 ms 35032 KB Output is correct
45 Correct 67 ms 37472 KB Output is correct
46 Correct 66 ms 39564 KB Output is correct
47 Correct 47 ms 41532 KB Output is correct
48 Correct 51 ms 43660 KB Output is correct
49 Correct 47 ms 45560 KB Output is correct
50 Correct 138 ms 47844 KB Output is correct
51 Correct 146 ms 50268 KB Output is correct
52 Correct 135 ms 52340 KB Output is correct
53 Correct 146 ms 54748 KB Output is correct
54 Correct 141 ms 56840 KB Output is correct
55 Correct 153 ms 59488 KB Output is correct
56 Correct 130 ms 61184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
8 Correct 2 ms 656 KB Output is correct
9 Correct 33 ms 3108 KB Output is correct
10 Correct 11 ms 3108 KB Output is correct
11 Correct 23 ms 4084 KB Output is correct
12 Correct 22 ms 5072 KB Output is correct
13 Correct 29 ms 6448 KB Output is correct
14 Correct 20 ms 6972 KB Output is correct
15 Correct 6 ms 6972 KB Output is correct
16 Correct 20 ms 8020 KB Output is correct
17 Correct 47 ms 11032 KB Output is correct
18 Correct 27 ms 11556 KB Output is correct
19 Correct 2 ms 11556 KB Output is correct
20 Correct 2 ms 11556 KB Output is correct
21 Correct 2 ms 11556 KB Output is correct
22 Correct 2 ms 11556 KB Output is correct
23 Correct 2 ms 11556 KB Output is correct
24 Correct 2 ms 11556 KB Output is correct
25 Correct 2 ms 11556 KB Output is correct
26 Correct 2 ms 11556 KB Output is correct
27 Correct 2 ms 11556 KB Output is correct
28 Correct 2 ms 11556 KB Output is correct
29 Correct 2 ms 11556 KB Output is correct
30 Correct 2 ms 11556 KB Output is correct
31 Correct 2 ms 11556 KB Output is correct
32 Correct 2 ms 11556 KB Output is correct
33 Correct 2 ms 11556 KB Output is correct
34 Correct 14 ms 11728 KB Output is correct
35 Correct 39 ms 13964 KB Output is correct
36 Correct 46 ms 15868 KB Output is correct
37 Correct 56 ms 17244 KB Output is correct
38 Correct 62 ms 18956 KB Output is correct
39 Correct 35 ms 19968 KB Output is correct
40 Correct 2 ms 19968 KB Output is correct
41 Correct 22 ms 20008 KB Output is correct
42 Correct 41 ms 22248 KB Output is correct
43 Correct 6 ms 22248 KB Output is correct
44 Correct 25 ms 22700 KB Output is correct
45 Correct 32 ms 23996 KB Output is correct
46 Correct 45 ms 25992 KB Output is correct
47 Correct 29 ms 25992 KB Output is correct
48 Correct 3 ms 25992 KB Output is correct
49 Correct 63 ms 28564 KB Output is correct
50 Correct 54 ms 30888 KB Output is correct
51 Correct 85 ms 32720 KB Output is correct
52 Correct 51 ms 35032 KB Output is correct
53 Correct 67 ms 37472 KB Output is correct
54 Correct 66 ms 39564 KB Output is correct
55 Correct 47 ms 41532 KB Output is correct
56 Correct 51 ms 43660 KB Output is correct
57 Correct 47 ms 45560 KB Output is correct
58 Correct 138 ms 47844 KB Output is correct
59 Correct 146 ms 50268 KB Output is correct
60 Correct 135 ms 52340 KB Output is correct
61 Correct 146 ms 54748 KB Output is correct
62 Correct 141 ms 56840 KB Output is correct
63 Correct 153 ms 59488 KB Output is correct
64 Correct 130 ms 61184 KB Output is correct
65 Correct 2 ms 61184 KB Output is correct
66 Incorrect 2 ms 61184 KB Output isn't correct
67 Halted 0 ms 0 KB -