Submission #338398

# Submission time Handle Problem Language Result Execution time Memory
338398 2020-12-23T05:16:28 Z boykut Chessboard (IZhO18_chessboard) C++14
16 / 100
34 ms 3180 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int isprime(int n) {
   if (n == 2) return false;
   for (int i = 2; i < n; i++) {
      if (n % i == 0) return false;
   }
   return true;
}

signed main() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   int n, k;
   cin >> n >> k;
   if (k == 0) {
      int ans = -1;
      for (int i = 2; i <= n; i++) {
         if (n % i == 0) {
            int m = n / i;
            
            int res = ((n * n) / (m * m)) / 2 * (m * m);
            
            if (ans == -1 || ans > res)
               ans = res;
         }
      }
      cout << ans << '\n';
      return 0;
   }
   bool ok = true;
   vector <int> x1(k), x2(k), y1(k), y2(k);
   for (int i = 0; i < k; i++) {
      cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      if (x1[i] != x2[i] || y1[i] != y2[i])
         ok = false;
   }
   if (ok && isprime(n)) {      
      int cnt[] = {0, 0};
      for (int i = 0, x, y; i < k; i++) {
         x = x1[i]; y = y1[i];
         cnt[(x + y) % 2]++;
      }
      if (n == 2) {
         cout << min(2 - cnt[0] + cnt[1], 2 - cnt[1] + cnt[0]);
      } else {
         cout << min(n * n / 2 + 1 - cnt[0] + cnt[1], n * n / 2 - cnt[1] + cnt[0]);
      }
      return 0;
   }
   if (ok && n <= 1000) {
      vector <vector <int> > mas(n,vector <int> (n, 0));
     
   }
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2284 KB Output is correct
2 Correct 7 ms 876 KB Output is correct
3 Correct 16 ms 1536 KB Output is correct
4 Correct 17 ms 1772 KB Output is correct
5 Correct 22 ms 2028 KB Output is correct
6 Correct 14 ms 1388 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 14 ms 1536 KB Output is correct
9 Correct 34 ms 3180 KB Output is correct
10 Correct 20 ms 1900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2284 KB Output is correct
2 Correct 7 ms 876 KB Output is correct
3 Correct 16 ms 1536 KB Output is correct
4 Correct 17 ms 1772 KB Output is correct
5 Correct 22 ms 2028 KB Output is correct
6 Correct 14 ms 1388 KB Output is correct
7 Correct 4 ms 620 KB Output is correct
8 Correct 14 ms 1536 KB Output is correct
9 Correct 34 ms 3180 KB Output is correct
10 Correct 20 ms 1900 KB Output is correct
11 Incorrect 1 ms 364 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 27 ms 2284 KB Output is correct
10 Correct 7 ms 876 KB Output is correct
11 Correct 16 ms 1536 KB Output is correct
12 Correct 17 ms 1772 KB Output is correct
13 Correct 22 ms 2028 KB Output is correct
14 Correct 14 ms 1388 KB Output is correct
15 Correct 4 ms 620 KB Output is correct
16 Correct 14 ms 1536 KB Output is correct
17 Correct 34 ms 3180 KB Output is correct
18 Correct 20 ms 1900 KB Output is correct
19 Incorrect 1 ms 364 KB Output isn't correct
20 Halted 0 ms 0 KB -