Submission #59163819


Source Code Expand

/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/

#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define isz(x) (int)x.size()
using namespace std;

void solve() {
    int n, q;
    cin >> n >> q;
    auto check = [&](int x, int y) -> bool {
        return 0 <= x and x < n and 0 <= y and y < n;
    };
    map<pair<int, int>, int> mp;
    while (q--) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        for (int i = -1; i <= 1; i += 2) for (int j = -1; j <= 1; j += 2) {
            int dx, dy;
            dx = i * 2, dy = j;
            if (check(x + dx, y + dy)) mp[{x + dx, y + dy}] = 0;
            dx = i, dy = j * 2;
            if (check(x + dx, y + dy)) mp[{x + dx, y + dy}] = 0;
        }
        mp[{x, y}] = 0;
    }
    cout << 1ll * n * n - isz(mp) << endl;
}

signed main() {

#ifndef CDuongg
    if (fopen(taskname".inp", "r"))
        assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
    freopen("bai3.inp", "r", stdin);
    freopen("bai3.out", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1; //cin >> t;
    while(t--) solve();

#ifdef CDuongg
   auto end = chrono::high_resolution_clock::now();
   cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
   cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
#endif

}

Submission Info

Submission Time
Task C - Avoid Knight Attack
User Thanhs
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1683 Byte
Status AC
Exec Time 637 ms
Memory 115984 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 35
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3396 KiB
00_sample_01.txt AC 1 ms 3604 KiB
00_sample_02.txt AC 1 ms 3400 KiB
01_random_03.txt AC 382 ms 16184 KiB
01_random_04.txt AC 557 ms 57456 KiB
01_random_05.txt AC 637 ms 115936 KiB
01_random_06.txt AC 520 ms 115880 KiB
01_random_07.txt AC 493 ms 115824 KiB
01_random_08.txt AC 491 ms 115984 KiB
01_random_09.txt AC 78 ms 8116 KiB
01_random_10.txt AC 399 ms 36924 KiB
01_random_11.txt AC 310 ms 61596 KiB
01_random_12.txt AC 26 ms 11784 KiB
01_random_13.txt AC 353 ms 87344 KiB
01_random_14.txt AC 44 ms 17080 KiB
01_random_15.txt AC 1 ms 3464 KiB
01_random_16.txt AC 1 ms 3468 KiB
01_random_17.txt AC 1 ms 3516 KiB
01_random_18.txt AC 1 ms 3472 KiB
01_random_19.txt AC 1 ms 3604 KiB
01_random_20.txt AC 1 ms 3480 KiB
01_random_21.txt AC 1 ms 3424 KiB
01_random_22.txt AC 1 ms 3424 KiB
01_random_23.txt AC 382 ms 16128 KiB
01_random_24.txt AC 505 ms 46024 KiB
01_random_25.txt AC 489 ms 67452 KiB
01_random_26.txt AC 466 ms 67388 KiB
01_random_27.txt AC 428 ms 67672 KiB
01_random_28.txt AC 432 ms 67592 KiB
01_random_29.txt AC 2 ms 3920 KiB
01_random_30.txt AC 79 ms 8104 KiB
01_random_31.txt AC 276 ms 57872 KiB
01_random_32.txt AC 10 ms 6236 KiB
01_random_33.txt AC 1 ms 3532 KiB
01_random_34.txt AC 175 ms 47808 KiB