답안 #855847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855847 2023-10-02T03:15:39 Z Trisanu_Das Chessboard (IZhO18_chessboard) C++17
8 / 100
49 ms 4448 KB
#include <iostream>
#include <algorithm>
#include <climits>
#define int long long
using namespace std;
 
int f(int s, int a) {
	a %= s * 2;
	return min(a, s * 2 - a);
}
 
signed main() {
	int n, k, temp, ans;
	cin >> n >> k;
    int x1[n], y1[n], x2[n], y2[n];
	for (int i = 0; i < k; i++){
      cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
      --x1[i]; --y1[i];
    }
	ans = LLONG_MAX;
	for (int i = 1; i < n; i++)
		if (n % i == 0) {
			temp = (n / i) * (n / i) / 2 * i * i;
			for (int j = 0; j < k; j++) temp += (f(i, x2[j]) - f(i, x1[j])) * (f(i, y2[j]) - f(i, y1[j]));
			ans = min(ans, min(temp, n * n - temp));
		}
	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 49 ms 4448 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 49 ms 4448 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Runtime error 49 ms 4448 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -