답안 #683537

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
683537 2023-01-18T16:40:52 Z Ronin13 Chessboard (IZhO18_chessboard) C++14
47 / 100
132 ms 3356 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
/*
6 8
3 3 3 3
1 2 1 2
3 4 3 4
5 5 5 5
4 3 4 3
4 4 4 4
2 1 2 1
3 6 3 6
*/



ll C(ll x1, ll y1, ll x2, ll y2, ll a){

    ll X = (x1 / a);
    ll Y = (y1 / a);
    if((X + Y) & 1) return 1;
    return -1;

}

int main(){
  //  freopen("school.in", "r", stdin);
 // freopen("school.out", "w", stdout);
    ll n, k;
    cin >> n >> k;
    ll x1[k + 1], x2[k + 1], y1[k + 1], y2[k + 1];
    for(int i =  1; i <= k; ++i){
        cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        x1[i]--;
        y1[i]--;
        x2[i]--;
        y2[i]--;
    }
    ll ans = 1e18 + 1;
    for(int a = 1; a <n; a++){
        if(n % a) continue;
        ll v = n / a;
        ll cnt = 0;
        if(v % 2 == 1)
            cnt += v * (v / 2) + (v + 1)  / 2;
        else cnt = v * v / 2;
        cnt *= a * a;
        for(int i = 1; i <= k; i++){
            int X = (x1[i] / a);
            int Y = (y1[i] / a);
            if((X + Y) & 1) cnt++;
            else cnt--;
        }
        ans = min(ans, cnt);
    }
    for(ll a = 1; a <n; a++){
        if(n % a) continue;
        ll v = n / a;
        ll cnt = -1;
        if(v % 2 == 1)
            cnt += v * (v / 2) + (v + 1) / 2;
        else cnt = v * v / 2;
        cnt *= a * a;
        for(int i = 1; i <= k; i++){
            int X = (x1[i] / a);
            int Y = (y1[i] / a);
            if((X + Y) & 1) cnt--;
            else cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 2228 KB Output is correct
2 Correct 19 ms 724 KB Output is correct
3 Correct 43 ms 1492 KB Output is correct
4 Correct 43 ms 1704 KB Output is correct
5 Correct 56 ms 1980 KB Output is correct
6 Correct 37 ms 1356 KB Output is correct
7 Correct 8 ms 524 KB Output is correct
8 Correct 37 ms 1492 KB Output is correct
9 Correct 94 ms 3096 KB Output is correct
10 Correct 56 ms 1840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 27 ms 1128 KB Output is correct
17 Correct 69 ms 2900 KB Output is correct
18 Correct 84 ms 3284 KB Output is correct
19 Correct 118 ms 3000 KB Output is correct
20 Correct 132 ms 3356 KB Output is correct
21 Correct 64 ms 2808 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 44 ms 1492 KB Output is correct
24 Correct 77 ms 3092 KB Output is correct
25 Correct 8 ms 468 KB Output is correct
26 Correct 53 ms 2004 KB Output is correct
27 Correct 60 ms 2392 KB Output is correct
28 Correct 79 ms 3260 KB Output is correct
29 Correct 27 ms 1332 KB Output is correct
30 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 2228 KB Output is correct
2 Correct 19 ms 724 KB Output is correct
3 Correct 43 ms 1492 KB Output is correct
4 Correct 43 ms 1704 KB Output is correct
5 Correct 56 ms 1980 KB Output is correct
6 Correct 37 ms 1356 KB Output is correct
7 Correct 8 ms 524 KB Output is correct
8 Correct 37 ms 1492 KB Output is correct
9 Correct 94 ms 3096 KB Output is correct
10 Correct 56 ms 1840 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 27 ms 1128 KB Output is correct
27 Correct 69 ms 2900 KB Output is correct
28 Correct 84 ms 3284 KB Output is correct
29 Correct 118 ms 3000 KB Output is correct
30 Correct 132 ms 3356 KB Output is correct
31 Correct 64 ms 2808 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 44 ms 1492 KB Output is correct
34 Correct 77 ms 3092 KB Output is correct
35 Correct 8 ms 468 KB Output is correct
36 Correct 53 ms 2004 KB Output is correct
37 Correct 60 ms 2392 KB Output is correct
38 Correct 79 ms 3260 KB Output is correct
39 Correct 27 ms 1332 KB Output is correct
40 Correct 3 ms 340 KB Output is correct
41 Incorrect 127 ms 2860 KB Output isn't correct
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 73 ms 2228 KB Output is correct
10 Correct 19 ms 724 KB Output is correct
11 Correct 43 ms 1492 KB Output is correct
12 Correct 43 ms 1704 KB Output is correct
13 Correct 56 ms 1980 KB Output is correct
14 Correct 37 ms 1356 KB Output is correct
15 Correct 8 ms 524 KB Output is correct
16 Correct 37 ms 1492 KB Output is correct
17 Correct 94 ms 3096 KB Output is correct
18 Correct 56 ms 1840 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 27 ms 1128 KB Output is correct
35 Correct 69 ms 2900 KB Output is correct
36 Correct 84 ms 3284 KB Output is correct
37 Correct 118 ms 3000 KB Output is correct
38 Correct 132 ms 3356 KB Output is correct
39 Correct 64 ms 2808 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 44 ms 1492 KB Output is correct
42 Correct 77 ms 3092 KB Output is correct
43 Correct 8 ms 468 KB Output is correct
44 Correct 53 ms 2004 KB Output is correct
45 Correct 60 ms 2392 KB Output is correct
46 Correct 79 ms 3260 KB Output is correct
47 Correct 27 ms 1332 KB Output is correct
48 Correct 3 ms 340 KB Output is correct
49 Incorrect 127 ms 2860 KB Output isn't correct
50 Halted 0 ms 0 KB -