답안 #747054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747054 2023-05-23T14:12:26 Z heeheeheehaaw Chessboard (IZhO18_chessboard) C++17
39 / 100
101 ms 13604 KB
#include <iostream>
#include <vector>

using namespace std;

int a[1005][1005];
int spw[1005][1005], spb[1005][1005];

int main()
{
    int n, k;
    cin>>n>>k;
    for(int i = 1; i <= k; i++)
    {
        int x1, y1, x2, y2;
        cin>>x1>>y1>>x2>>y2;
        a[x1][y1] = 1;
    }

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
        {
            if(a[i][j] == 0) spw[i][j]++;
            else spb[i][j]++;
            spw[i][j] += spw[i][j - 1] + spw[i - 1][j] - spw[i - 1][j - 1];
            spb[i][j] += spb[i][j - 1] + spb[i - 1][j] - spb[i - 1][j - 1];
        }

    vector<int> divs;
    for(int i = 1; i * i <= n; i++)
        if(n % i == 0)
        {
            divs.push_back(i);
            if(i * i != n && i != 1)
                divs.push_back(n / i);
        }

    int minn = n * n;
    for(auto d : divs)
    {
        for(int pas = 0; pas <= 1; pas++)
        {
            int col = pas, sum = 0;
            for(int i = d; i <= n; i += d)
            {
                if((i / d) % 2 == 0)
                    col = pas;
                else
                    col = 1 - pas;
                for(int j = d; j <= n; j += d)
                {
                    if(col == 0)
                        sum += spb[i][j] - spb[i - d][j] - spb[i][j - d] + spb[i - d][j - d];
                    else
                        sum += spw[i][j] - spw[i - d][j] - spw[i][j - d] + spw[i - d][j - d];
                    col = 1 - col;
                }
            }

            minn = min(minn, sum);
        }
    }

    cout<<minn<<'\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 444 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 944 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 2 ms 1356 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 2 ms 1336 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 2 ms 980 KB Output is correct
12 Correct 1 ms 948 KB Output is correct
13 Correct 2 ms 1088 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 944 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 2 ms 1236 KB Output is correct
5 Correct 1 ms 1236 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 2 ms 1356 KB Output is correct
8 Correct 1 ms 980 KB Output is correct
9 Correct 2 ms 1336 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 2 ms 980 KB Output is correct
12 Correct 1 ms 948 KB Output is correct
13 Correct 2 ms 1088 KB Output is correct
14 Correct 2 ms 1108 KB Output is correct
15 Correct 2 ms 828 KB Output is correct
16 Correct 34 ms 11904 KB Output is correct
17 Correct 82 ms 13424 KB Output is correct
18 Correct 100 ms 13604 KB Output is correct
19 Correct 96 ms 13012 KB Output is correct
20 Correct 98 ms 13144 KB Output is correct
21 Correct 97 ms 13284 KB Output is correct
22 Correct 15 ms 9660 KB Output is correct
23 Correct 66 ms 12424 KB Output is correct
24 Correct 101 ms 13400 KB Output is correct
25 Correct 30 ms 11760 KB Output is correct
26 Correct 69 ms 12476 KB Output is correct
27 Correct 74 ms 12772 KB Output is correct
28 Correct 94 ms 13132 KB Output is correct
29 Correct 64 ms 12296 KB Output is correct
30 Correct 20 ms 11628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 444 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 1 ms 980 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 1 ms 948 KB Output is correct
9 Runtime error 1 ms 444 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -