Submission #342686

# Submission time Handle Problem Language Result Execution time Memory
342686 2021-01-02T16:12:17 Z koketsu Chessboard (IZhO18_chessboard) C++14
16 / 100
32 ms 372 KB
#include <bits/stdc++.h>
#define pb push_back
#define LL long long
#define Kultivator ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int LL

using namespace std;

const LL Mxn = 1e6 + 7;
const LL Mod = 1e9 + 7;
const LL Inf = 1e14 + 7;

int N, K;

bool isprime(int n){
	if(n == 2) return true;
	for(int i = 2; i*i <= n; i++)
		if(n%i == 0) return false;
	return true;
}

bool Get(int x, int y, int d){
    return (x / d + y / d) % 2;
}

void Ans1(){
    int Ans = Mxn;
    for(int i = 1; i < N; i++){
        if(N % i == 0){
            Ans = min(Ans, (N * N) / (2 * i * i) * (i * i));
        }
    }
    cout << Ans;
}

void Ans2(){
	int cnt[2] = {0, 0};
	for(int i = 1; i <= K; i++){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		for(int x = x1; x <= x2; x++)
		for(int y = y1; y <= y2; y++){
			//a[x][y] = 1;
			cnt[(x+y)%2]++;
		}
	}

	cout << min(N*N/2-cnt[1] + cnt[0], N*N/2+1-cnt[0] + cnt[1]);
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> K;
    if(K == 0){
        Ans1();
    } else if(isprime(N)){
        Ans2();
    }
    //Ans3(N, K);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
3 Correct 14 ms 364 KB Output is correct
4 Correct 16 ms 364 KB Output is correct
5 Correct 20 ms 372 KB Output is correct
6 Correct 13 ms 364 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 13 ms 364 KB Output is correct
9 Correct 32 ms 364 KB Output is correct
10 Correct 18 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
3 Correct 14 ms 364 KB Output is correct
4 Correct 16 ms 364 KB Output is correct
5 Correct 20 ms 372 KB Output is correct
6 Correct 13 ms 364 KB Output is correct
7 Correct 3 ms 364 KB Output is correct
8 Correct 13 ms 364 KB Output is correct
9 Correct 32 ms 364 KB Output is correct
10 Correct 18 ms 364 KB Output is correct
11 Incorrect 0 ms 364 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 22 ms 364 KB Output is correct
10 Correct 7 ms 364 KB Output is correct
11 Correct 14 ms 364 KB Output is correct
12 Correct 16 ms 364 KB Output is correct
13 Correct 20 ms 372 KB Output is correct
14 Correct 13 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 13 ms 364 KB Output is correct
17 Correct 32 ms 364 KB Output is correct
18 Correct 18 ms 364 KB Output is correct
19 Incorrect 0 ms 364 KB Output isn't correct
20 Halted 0 ms 0 KB -