Submission #521788

# Submission time Handle Problem Language Result Execution time Memory
521788 2022-02-03T06:41:17 Z vonatlus Chessboard (IZhO18_chessboard) C++17
70 / 100
225 ms 2628 KB
/// adil sultanov | vonat1us 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 1e5+10;

void ma1n() {
    ll n, k;
    cin >> n >> k;
    vector<int> v;
    for (int i = 1; i <= sqrt(n); ++i) {
        if (n%i == 0) {
            v.pb(i);
            if (i*i != n) {
                v.pb(n/i);
            }
        }
    }
    sort(all(v));
    v.pop_back();
    vector<ll> res1(sz(v)), res2(sz(v));
    for (int i = 0; i < sz(v); ++i) {
        ll d = v[i];
        ll cnt = n/d;
        ll cnt1 = cnt/2;
        ll cnt2 = (cnt+1)/2;
        res1[i] = cnt1*cnt2*d*d*2;
        res2[i] = n*n - res1[i];
    }
    while (k--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;    
        for (int t = 0; t < sz(v); ++t) {
            int dv = v[t];
            int i = a/dv;
            int j = b/dv;
            if (i%2 != j%2) {
                res1[t]--;
                res2[t]++;
            } else {
                res1[t]++;
                res2[t]--;
            }
        }
    }
    ll ans = n*n;
    for (int i = 0; i < sz(v); ++i) {
        ans = min({ans, res1[i], res2[i]});    
    }
    cout << ans;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1784 KB Output is correct
2 Correct 5 ms 588 KB Output is correct
3 Correct 12 ms 1176 KB Output is correct
4 Correct 13 ms 1088 KB Output is correct
5 Correct 23 ms 1472 KB Output is correct
6 Correct 11 ms 1044 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 12 ms 1120 KB Output is correct
9 Correct 30 ms 2324 KB Output is correct
10 Correct 15 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 8 ms 716 KB Output is correct
17 Correct 23 ms 1564 KB Output is correct
18 Correct 26 ms 1904 KB Output is correct
19 Correct 58 ms 1684 KB Output is correct
20 Correct 60 ms 1828 KB Output is correct
21 Correct 20 ms 1612 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 15 ms 920 KB Output is correct
24 Correct 25 ms 1696 KB Output is correct
25 Correct 3 ms 432 KB Output is correct
26 Correct 17 ms 1196 KB Output is correct
27 Correct 21 ms 1312 KB Output is correct
28 Correct 27 ms 1732 KB Output is correct
29 Correct 8 ms 844 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1784 KB Output is correct
2 Correct 5 ms 588 KB Output is correct
3 Correct 12 ms 1176 KB Output is correct
4 Correct 13 ms 1088 KB Output is correct
5 Correct 23 ms 1472 KB Output is correct
6 Correct 11 ms 1044 KB Output is correct
7 Correct 3 ms 456 KB Output is correct
8 Correct 12 ms 1120 KB Output is correct
9 Correct 30 ms 2324 KB Output is correct
10 Correct 15 ms 1484 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 316 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 8 ms 716 KB Output is correct
27 Correct 23 ms 1564 KB Output is correct
28 Correct 26 ms 1904 KB Output is correct
29 Correct 58 ms 1684 KB Output is correct
30 Correct 60 ms 1828 KB Output is correct
31 Correct 20 ms 1612 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 15 ms 920 KB Output is correct
34 Correct 25 ms 1696 KB Output is correct
35 Correct 3 ms 432 KB Output is correct
36 Correct 17 ms 1196 KB Output is correct
37 Correct 21 ms 1312 KB Output is correct
38 Correct 27 ms 1732 KB Output is correct
39 Correct 8 ms 844 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 56 ms 2244 KB Output is correct
42 Correct 31 ms 2500 KB Output is correct
43 Correct 38 ms 2208 KB Output is correct
44 Correct 31 ms 2496 KB Output is correct
45 Correct 29 ms 2628 KB Output is correct
46 Correct 60 ms 2456 KB Output is correct
47 Correct 26 ms 2336 KB Output is correct
48 Correct 33 ms 2324 KB Output is correct
49 Correct 27 ms 2212 KB Output is correct
50 Correct 201 ms 2372 KB Output is correct
51 Correct 219 ms 2600 KB Output is correct
52 Correct 202 ms 2364 KB Output is correct
53 Correct 217 ms 2500 KB Output is correct
54 Correct 208 ms 2336 KB Output is correct
55 Correct 225 ms 2620 KB Output is correct
56 Correct 200 ms 2460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 20 ms 1784 KB Output is correct
10 Correct 5 ms 588 KB Output is correct
11 Correct 12 ms 1176 KB Output is correct
12 Correct 13 ms 1088 KB Output is correct
13 Correct 23 ms 1472 KB Output is correct
14 Correct 11 ms 1044 KB Output is correct
15 Correct 3 ms 456 KB Output is correct
16 Correct 12 ms 1120 KB Output is correct
17 Correct 30 ms 2324 KB Output is correct
18 Correct 15 ms 1484 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 316 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 316 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 8 ms 716 KB Output is correct
35 Correct 23 ms 1564 KB Output is correct
36 Correct 26 ms 1904 KB Output is correct
37 Correct 58 ms 1684 KB Output is correct
38 Correct 60 ms 1828 KB Output is correct
39 Correct 20 ms 1612 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 15 ms 920 KB Output is correct
42 Correct 25 ms 1696 KB Output is correct
43 Correct 3 ms 432 KB Output is correct
44 Correct 17 ms 1196 KB Output is correct
45 Correct 21 ms 1312 KB Output is correct
46 Correct 27 ms 1732 KB Output is correct
47 Correct 8 ms 844 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 56 ms 2244 KB Output is correct
50 Correct 31 ms 2500 KB Output is correct
51 Correct 38 ms 2208 KB Output is correct
52 Correct 31 ms 2496 KB Output is correct
53 Correct 29 ms 2628 KB Output is correct
54 Correct 60 ms 2456 KB Output is correct
55 Correct 26 ms 2336 KB Output is correct
56 Correct 33 ms 2324 KB Output is correct
57 Correct 27 ms 2212 KB Output is correct
58 Correct 201 ms 2372 KB Output is correct
59 Correct 219 ms 2600 KB Output is correct
60 Correct 202 ms 2364 KB Output is correct
61 Correct 217 ms 2500 KB Output is correct
62 Correct 208 ms 2336 KB Output is correct
63 Correct 225 ms 2620 KB Output is correct
64 Correct 200 ms 2460 KB Output is correct
65 Correct 0 ms 204 KB Output is correct
66 Incorrect 0 ms 304 KB Output isn't correct
67 Halted 0 ms 0 KB -