답안 #917721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917721 2024-01-28T16:44:29 Z dilanyan Chessboard (IZhO18_chessboard) C++17
39 / 100
61 ms 2812 KB
//-------------dilanyan------------\\ 
 
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
 
//------------------KarginDefines--------------------\\ 
 
#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
#define Kargin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Usaco freopen(".in", "r", stdin); freopen(".out", "w", stdout);
 
 
//-------------------KarginConstants------------------\\ 
 
const ll mod = 1000000007;
const ll inf = 1e9 + 15;
 
//-------------------KarginCode------------------------\\ 
 
const int N = 100005;
int x[N], y[N];

void KarginSolve() {
    ll n, k;
    cin >> n >> k;
    int sq = sqrt(n);
    vector<ll> div;
    for (int i = 1;i <= sq;i++) {
        if (n % i == 0) {
            div.pb(i);
            if (i * i != n) div.pb(n / i);
        }
    }
    for (int i = 0;i < k;i++) cin >> x[i] >> y[i] >> x[i] >> y[i];
    ll ans = inf;
    for (ll d : div) {
        if (d == n) continue;
        ll c = (n * n) / (d * d);
        ll fw = c / 2, fb = (c + 1) / 2;
        fw *= d * d, fb *= d * d;
        for (int i = 0;i < k;i++) {
            int dx = (x[i] + d - 1) / d, dy = (y[i] + d - 1) / d;
            if (dx & 1) {
                if (dy & 1) fw++, fb--;
                else fw--, fb++;
            }
            else {
                if (dy & 1) fw--, fb++;
                else fw++, fb--;
            }
        }
        ans = min(ans, min(fw, fb));
    }
    cout << ans << '\n';
}
 
int main() {
    //Usaco
    Kargin;
    int test = 1;
    //cin >> test;
    while (test--) {
        KarginSolve();
    }
    return 0;
}

Compilation message

chessboard.cpp:1:1: warning: multi-line comment [-Wcomment]
    1 | //-------------dilanyan------------\\
      | ^
chessboard.cpp:8:1: warning: multi-line comment [-Wcomment]
    8 | //------------------KarginDefines--------------------\\
      | ^
chessboard.cpp:22:1: warning: multi-line comment [-Wcomment]
   22 | //-------------------KarginConstants------------------\\
      | ^
chessboard.cpp:27:1: warning: multi-line comment [-Wcomment]
   27 | //-------------------KarginCode------------------------\\
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 2416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 472 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 724 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 472 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 724 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 7 ms 1112 KB Output is correct
17 Correct 18 ms 2396 KB Output is correct
18 Correct 24 ms 2804 KB Output is correct
19 Correct 54 ms 2564 KB Output is correct
20 Correct 61 ms 2812 KB Output is correct
21 Correct 21 ms 2376 KB Output is correct
22 Correct 1 ms 756 KB Output is correct
23 Correct 13 ms 1368 KB Output is correct
24 Correct 23 ms 2524 KB Output is correct
25 Correct 3 ms 668 KB Output is correct
26 Correct 14 ms 1628 KB Output is correct
27 Correct 19 ms 1884 KB Output is correct
28 Correct 23 ms 2644 KB Output is correct
29 Correct 10 ms 1116 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 2416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 17 ms 2416 KB Output isn't correct
10 Halted 0 ms 0 KB -