답안 #861611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861611 2023-10-16T14:52:02 Z PagodePaiva Chessboard (IZhO18_chessboard) C++17
39 / 100
302 ms 10064 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 or n == 3){
        int res1 = 0;
        int res2 = 0;
        int p = n;

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

        else{
            res1 = (p*p+1)/2;
            res2 = (p*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 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 448 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4544 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4532 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4544 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4532 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2408 KB Output is correct
16 Correct 44 ms 9816 KB Output is correct
17 Correct 64 ms 9816 KB Output is correct
18 Correct 99 ms 10064 KB Output is correct
19 Correct 292 ms 9564 KB Output is correct
20 Correct 302 ms 9656 KB Output is correct
21 Correct 70 ms 9820 KB Output is correct
22 Correct 147 ms 8796 KB Output is correct
23 Correct 91 ms 9560 KB Output is correct
24 Correct 82 ms 9816 KB Output is correct
25 Correct 72 ms 9812 KB Output is correct
26 Correct 61 ms 9560 KB Output is correct
27 Correct 90 ms 9564 KB Output is correct
28 Correct 82 ms 9560 KB Output is correct
29 Correct 32 ms 9560 KB Output is correct
30 Correct 32 ms 9320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 344 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 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 448 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 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 Incorrect 47 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -