Submission #59178904


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

// 座標y,xが高さh幅wの範囲内か(開始座標(0,0))
bool in_mass(int y, int x, int h, int w) {
    return x >= 0 && y >= 0 && x < w && y < h;
}

int main() {
    long long n, m;
    cin >> n >> m;

    set<pair<int, int>> ng_set;

    vector<pair<int, int>> ps(m);
    for(int i = 0; i < m; i++) {
        int x, y;
        cin >> y >> x;
        y--;
        x--;
        ps[i] = make_pair(y, x);

        ng_set.insert(make_pair(y, x));
    }
    // cout << ps[0][0] << endl;

    const int dy[8] = {2, 1, -1, -2, -2, -1, +1, +2};
    const int dx[8] = {1, 2, 2, 1, -1, -2, -2, -1};

    // cout << "-----" << endl;
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < 8; j++) {
            int y = ps[i].first + dy[j];
            int x = ps[i].second + dx[j];
            if(in_mass(y, x, n, n)) {
                // cout << y << " " << x << endl;
                ng_set.insert(make_pair(y, x));
            }
        }
    }

    cout << n * n - ng_set.size() << endl;

    return 0;
}

Submission Info

Submission Time
Task C - Avoid Knight Attack
User nnth_y
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1105 Byte
Status AC
Exec Time 733 ms
Memory 89160 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 3500 KiB
00_sample_01.txt AC 1 ms 3560 KiB
00_sample_02.txt AC 1 ms 3460 KiB
01_random_03.txt AC 462 ms 14236 KiB
01_random_04.txt AC 681 ms 45400 KiB
01_random_05.txt AC 733 ms 88892 KiB
01_random_06.txt AC 588 ms 89156 KiB
01_random_07.txt AC 568 ms 89120 KiB
01_random_08.txt AC 576 ms 89160 KiB
01_random_09.txt AC 89 ms 7060 KiB
01_random_10.txt AC 468 ms 29588 KiB
01_random_11.txt AC 342 ms 47512 KiB
01_random_12.txt AC 28 ms 9832 KiB
01_random_13.txt AC 407 ms 67316 KiB
01_random_14.txt AC 52 ms 13964 KiB
01_random_15.txt AC 1 ms 3452 KiB
01_random_16.txt AC 1 ms 3560 KiB
01_random_17.txt AC 1 ms 3652 KiB
01_random_18.txt AC 1 ms 3452 KiB
01_random_19.txt AC 1 ms 3528 KiB
01_random_20.txt AC 1 ms 3480 KiB
01_random_21.txt AC 1 ms 3572 KiB
01_random_22.txt AC 1 ms 3464 KiB
01_random_23.txt AC 463 ms 14196 KiB
01_random_24.txt AC 632 ms 36584 KiB
01_random_25.txt AC 612 ms 52728 KiB
01_random_26.txt AC 555 ms 52728 KiB
01_random_27.txt AC 568 ms 52728 KiB
01_random_28.txt AC 571 ms 52684 KiB
01_random_29.txt AC 2 ms 3956 KiB
01_random_30.txt AC 92 ms 7064 KiB
01_random_31.txt AC 306 ms 45428 KiB
01_random_32.txt AC 12 ms 5860 KiB
01_random_33.txt AC 1 ms 3484 KiB
01_random_34.txt AC 227 ms 37372 KiB