Submission #342655

# Submission time Handle Problem Language Result Execution time Memory
342655 2021-01-02T15:32:55 Z koketsu Chessboard (IZhO18_chessboard) C++14
Compilation error
0 ms 0 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);

using namespace std;

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

bool Prime(int N){
    bool Used = false;
    for(int i = 2; i <= sqrt(N); i++){
        if(N % i == 0){
            Used = true;
            break;
        }
    }
    return Used;
}

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

void Ans1(int N){
    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 N, int K){
    int cnt[2] = {0, 0};
    for(int i = 1; i <= K; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        bool Num = Get(y2, x2);
        cnt[(x+y)%2]++;	
    }
    cout << min((N * N) / 2 - Cnt[1] + Cnt[0], (N * N) / 2 + 1 - Cnt[0] + Cnt[1]);
}

int main(){
    Kultivator;
    LL N, K;
    cin >> N >> K;
    if(!K){
        Ans1(N);
    } else if(!Prime(N)){
        Ans2(N, K);
    }
    //cout << Prime(N);
}

Compilation message

chessboard.cpp: In function 'void Ans2(int, int)':
chessboard.cpp:43:14: error: 'x' was not declared in this scope; did you mean 'x2'?
   43 |         cnt[(x+y)%2]++;
      |              ^
      |              x2
chessboard.cpp:43:16: error: 'y' was not declared in this scope; did you mean 'y2'?
   43 |         cnt[(x+y)%2]++;
      |                ^
      |                y2
chessboard.cpp:42:14: warning: unused variable 'Num' [-Wunused-variable]
   42 |         bool Num = Get(y2, x2);
      |              ^~~
chessboard.cpp:45:31: error: 'Cnt' was not declared in this scope; did you mean 'cnt'?
   45 |     cout << min((N * N) / 2 - Cnt[1] + Cnt[0], (N * N) / 2 + 1 - Cnt[0] + Cnt[1]);
      |                               ^~~
      |                               cnt