답안 #338413

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338413 2020-12-23T05:29:47 Z BY_KUTBILIM Chessboard (IZhO18_chessboard) C++14
16 / 100
37 ms 1772 KB
/** @BY_KUTBILIM **/
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()

const int inf = (int)1e9+7;

bool prime(){
    
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();

    int k;
    ll n;
    cin >> n >> k;
    int x1[k], x2[k], y1[k], y2[k];
    vector<ll> div;
    div.pb(1);
    for(int i = 2; i <= sqrt(n); i++){
        if(n % i == 0){
            div.pb(i);
            if(i != n / i){
                div.pb(n/i);
            }
        }
    }
    sort(all(div));
    vector<ll> cnt1((int)div.size(), 0), cnt0((int)div.size(), 0);
    for(int i = 0; i < k; i++){
        cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        for(int j = 0; j < (int)div.size(); j++){
            if((x1[i] / div[j] + y1[i] / div[j]) % 2 == 0)cnt0[j]++;
            else cnt1[j]++;
        }
    }
    ll ans = n * n;
    for(int i = 0; i < (int)div.size(); i++){
        ans = min({ans, 
        n * n / (div[i] * div[i]) / 2ll * div[i] * div[i] + ((n * n / (div[i] * div[i]) % 2)) - cnt0[i] + cnt1[i],
        n * n / (div[i] * div[i]) / 2ll * div[i] * div[i] - cnt1[i] + cnt0[i]});
//        cout << div[i] << " " << n * n / (div[i] * div[i]) / 2ll + ((n * n / (div[i] * div[i]) % 2)) - cnt0[i] + cnt1[i] << " " << n * n / (div[i] * div[i]) / 2ll - cnt1[i] + cnt0[i] << endl;
    }
    cout << ans;

    return 0;
}

Compilation message

chessboard.cpp: In function 'bool prime()':
chessboard.cpp:16:1: warning: no return statement in function returning non-void [-Wreturn-type]
   16 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1260 KB Output is correct
2 Correct 7 ms 620 KB Output is correct
3 Correct 15 ms 1004 KB Output is correct
4 Correct 17 ms 1004 KB Output is correct
5 Correct 21 ms 1132 KB Output is correct
6 Correct 14 ms 876 KB Output is correct
7 Correct 3 ms 492 KB Output is correct
8 Correct 14 ms 876 KB Output is correct
9 Correct 37 ms 1772 KB Output is correct
10 Correct 21 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1260 KB Output is correct
2 Correct 7 ms 620 KB Output is correct
3 Correct 15 ms 1004 KB Output is correct
4 Correct 17 ms 1004 KB Output is correct
5 Correct 21 ms 1132 KB Output is correct
6 Correct 14 ms 876 KB Output is correct
7 Correct 3 ms 492 KB Output is correct
8 Correct 14 ms 876 KB Output is correct
9 Correct 37 ms 1772 KB Output is correct
10 Correct 21 ms 1132 KB Output is correct
11 Incorrect 1 ms 364 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 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 24 ms 1260 KB Output is correct
10 Correct 7 ms 620 KB Output is correct
11 Correct 15 ms 1004 KB Output is correct
12 Correct 17 ms 1004 KB Output is correct
13 Correct 21 ms 1132 KB Output is correct
14 Correct 14 ms 876 KB Output is correct
15 Correct 3 ms 492 KB Output is correct
16 Correct 14 ms 876 KB Output is correct
17 Correct 37 ms 1772 KB Output is correct
18 Correct 21 ms 1132 KB Output is correct
19 Incorrect 1 ms 364 KB Output isn't correct
20 Halted 0 ms 0 KB -