답안 #861610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861610 2023-10-16T14:50:30 Z PagodePaiva Chessboard (IZhO18_chessboard) C++14
39 / 100
310 ms 9976 KB
#include<bits/stdc++.h>
#define inf 1e18
#define int long long
#define N 1010

using namespace std;

int v[N][N];
int mark[N][N];

int32_t main(){
    int n, k;
    cin >> n >> k;

    if(n > N-1){
        int res1 = 0;
        int res2 = 0;
        int p = n;

        if(n % 2 == 0){
            res1 = 2;
            res2 = 2;
        }

        else{
            res1 = (p+1)/2;
            res2 = (p-1)/2;
        }

        for(int i = 1;i <= k;i++){
            int a, b, c, d;
            cin >> a >> b >> c >> d;
            if(a % 2 != b % 2){
                res1--;
                res2++;
            }

            else{
                res1++;
                res2--;
            }
        }

        cout << min(res1, res2) << '\n';    

        return 0;  
    }


    // vector <pair <int, int>> v;

    for(int i = 1;i <= k;i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        v[a][b] = 1;
    }

    int res = inf;

    for(int p = 1;p < n;p++){
        if(n % p != 0) continue;
        int resp = 0;

        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                int ti = (i-1)/p;
                int tj = (j-1)/p;

                if((ti % 2 )!= (tj % 2)){
                    if(v[i][j] != 0) resp++;
                }

                else{
                    if(v[i][j] != 1) resp++;
                }
            }
        }

        // cout << p << ' ' << resp << '\n';
        res = min(res, resp);
        resp = 0;

        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                int ti = (i-1)/p;
                int tj = (j-1)/p;

                if((ti % 2 )!= (tj % 2)){
                    if(v[i][j] != 1) resp++;
                }

                else{
                    if(v[i][j] != 0) resp++;
                }
            }
        }

        res = min(res, resp);
    }

    cout << res << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 2 ms 4440 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 2 ms 4440 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 47 ms 9564 KB Output is correct
17 Correct 74 ms 9820 KB Output is correct
18 Correct 88 ms 9936 KB Output is correct
19 Correct 310 ms 9564 KB Output is correct
20 Correct 302 ms 9808 KB Output is correct
21 Correct 65 ms 9976 KB Output is correct
22 Correct 146 ms 8792 KB Output is correct
23 Correct 92 ms 9744 KB Output is correct
24 Correct 99 ms 9820 KB Output is correct
25 Correct 74 ms 9564 KB Output is correct
26 Correct 69 ms 9616 KB Output is correct
27 Correct 94 ms 9564 KB Output is correct
28 Correct 82 ms 9560 KB Output is correct
29 Correct 31 ms 9560 KB Output is correct
30 Correct 34 ms 9308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Incorrect 47 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -