Submission #855834

# Submission time Handle Problem Language Result Execution time Memory
855834 2023-10-02T02:32:20 Z Trisanu_Das Chessboard (IZhO18_chessboard) C++17
0 / 100
54 ms 7476 KB
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;
#define int long long
 
int n, k, tot, x1[100000], x2[100000], y1[100000], y2[100000];
 
signed main(){
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    x1[i]--; x2[i]--; y2[i]--; y1[i]--;
    tot += (x2[i] - x1[i] + 1) * (y2[i] - y1[i] + 1);
  }
  int ans = LLONG_MAX;
  for(int i = 0; i < n; i++){
    if(n % i == 0){
      int alt1 = ((n / i) * (n / i)) / (2 * i * i), alt2 = ((n / i) * (n / i + 1)) / (2 * i * i), t = 0;
      for(int j = 0; j < k; j++) if(((x1[j] / i) & 1) == ((y1[j] / i) & 1)) t++;
      ans = min(ans, min((alt2 - t) + (tot - t), (alt1 - (tot - t)) + t));
    }
  }
  cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 54 ms 7476 KB Execution killed with signal 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4700 KB Execution killed with signal 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4700 KB Execution killed with signal 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 54 ms 7476 KB Execution killed with signal 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 4
2 Halted 0 ms 0 KB -