답안 #861609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861609 2023-10-16T14:49:59 Z PagodePaiva Chessboard (IZhO18_chessboard) C++14
39 / 100
322 ms 11396 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';      
    }


    // 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 356 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 48 ms 1884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4448 KB Output is correct
3 Correct 2 ms 4544 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 4444 KB Output is correct
7 Correct 2 ms 4696 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4544 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4448 KB Output is correct
3 Correct 2 ms 4544 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 4444 KB Output is correct
7 Correct 2 ms 4696 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4544 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 2396 KB Output is correct
16 Correct 44 ms 9820 KB Output is correct
17 Correct 97 ms 11212 KB Output is correct
18 Correct 92 ms 11328 KB Output is correct
19 Correct 310 ms 11088 KB Output is correct
20 Correct 322 ms 11344 KB Output is correct
21 Correct 66 ms 11084 KB Output is correct
22 Correct 147 ms 8908 KB Output is correct
23 Correct 94 ms 10424 KB Output is correct
24 Correct 108 ms 11396 KB Output is correct
25 Correct 75 ms 9844 KB Output is correct
26 Correct 61 ms 10520 KB Output is correct
27 Correct 96 ms 10792 KB Output is correct
28 Correct 92 ms 11328 KB Output is correct
29 Correct 35 ms 10076 KB Output is correct
30 Correct 32 ms 9560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 48 ms 1884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 356 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 0 ms 440 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Runtime error 48 ms 1884 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -