답안 #878738

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878738 2023-11-25T06:52:51 Z Elvin_Fritl Chessboard (IZhO18_chessboard) C++17
39 / 100
70 ms 5188 KB
#include <bits/stdc++.h>
using namespace std;
 
#define io                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

 
typedef long long ll;
 
ll bp(ll n,ll m){
    if(m == 0){
        return 1;
    }
    if(m == 1){
        return n;
    }
    if(m%2==0){
        return bp(n*n,m/2);
    }
    return n*bp(n,m-1);
}

 
const int N =  2505, M = 33, inf = 1e9 + 99;
const ll inff = 1e12;
 
int main()
{
	io;
	
	int n, k; 
	cin >> n >> k;
	ll res = n * n;
	ll a[k][4];
	for(int i=0;i<k;i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
	}
	for(int m=1;m<n;m++) {
		if(!(n % m)) { 
			ll tmp = (m * (n / (2 * m)) + min(m, n % (2 * m))) * (n - (m * (n / (2 * m)) + min(m, n % (2 * m)))) + (m * (n / (2 * m)) + min(m, n % (2 * m))) * (n - (m * (n / (2 * m)) + min(m, n % (2 * m))));
			for(int i=0;i<k;i++) {
				ll u = a[i][2] - a[i][0] + 1;
				ll x = (m * (a[i][2] / (2 * m)) + min(1LL * m, 1LL * a[i][2] % (2 * m))) - (m * ((a[i][0] - 1) / (2 * m)) + min(1LL * m,1LL *  (a[i][0] - 1) % (2 * m)));
				ll v = a[i][3] - a[i][1] + 1;
				ll y = (m * (a[i][3] / (2 * m)) + min(1LL * m, 1LL * a[i][3] % (2 * m))) - (m * ((a[i][1] - 1) / (2 * m)) + min(1LL * m, 1LL * (a[i][1] - 1) % (2LL * m)));;
				tmp += 2 * (x * y + (u - x) * (v - y)) - u * v;
			}
			res = min(res, min(tmp, n * n - tmp));
		}
	}
	cout << res << endl;
    
    return 0;
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 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 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 3900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 416 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 416 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 8 ms 1628 KB Output is correct
17 Correct 20 ms 4324 KB Output is correct
18 Correct 30 ms 5188 KB Output is correct
19 Correct 63 ms 4620 KB Output is correct
20 Correct 70 ms 4944 KB Output is correct
21 Correct 18 ms 4188 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 15 ms 2260 KB Output is correct
24 Correct 25 ms 4640 KB Output is correct
25 Correct 3 ms 604 KB Output is correct
26 Correct 15 ms 3132 KB Output is correct
27 Correct 20 ms 3420 KB Output is correct
28 Correct 25 ms 4952 KB Output is correct
29 Correct 8 ms 2292 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 3900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 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 376 KB Output is correct
9 Incorrect 17 ms 3900 KB Output isn't correct
10 Halted 0 ms 0 KB -