답안 #917737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917737 2024-01-28T17:02:06 Z dilanyan Chessboard (IZhO18_chessboard) C++17
39 / 100
57 ms 1884 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;
ll x[N], y[N];

void KarginSolve() {
    ll n, k;
    cin >> n >> k;
    ll sq = sqrt(n);
    vector<ll> div;
    for (ll 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 = fw * d * d, fb = 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 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 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 16 ms 1372 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 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 428 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 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 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 428 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 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 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 7 ms 860 KB Output is correct
17 Correct 17 ms 1724 KB Output is correct
18 Correct 24 ms 1760 KB Output is correct
19 Correct 52 ms 1828 KB Output is correct
20 Correct 57 ms 1884 KB Output is correct
21 Correct 17 ms 1624 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 13 ms 1112 KB Output is correct
24 Correct 21 ms 1624 KB Output is correct
25 Correct 3 ms 348 KB Output is correct
26 Correct 14 ms 1276 KB Output is correct
27 Correct 19 ms 1528 KB Output is correct
28 Correct 23 ms 1852 KB Output is correct
29 Correct 8 ms 1056 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 1372 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 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 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 16 ms 1372 KB Output isn't correct
10 Halted 0 ms 0 KB -