105032024-04-03 16:26:03MagyarKendeSZLGÜtős helyzet (75 pont)cpp17Accepted 75/753ms3160 KiB
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> v(8, vector<int>(8));

void setvals(int X, int Y, int type, bool diag, int val) {
    for (int i = Y + 1; i < 8; i++) {
        v[i][X] = val;
    }
    for (int i = Y - 1; i >= 0; i--) {
        v[i][X] = val;
    }
    for (int j = X + 1; j < 8; j++) {
        v[Y][j] = val;
    }
    for (int j = X - 1; j >= 0; j--) {
        v[Y][j] = val;
    }

    if (diag) {
        for (int i = Y + 1, j = X + 1; i < 8 && j < 8; i++, j++) {
            v[i][j] = val;
        }
        for (int i = Y - 1, j = X - 1; i >= 0 && j >= 0; i--, j--) {
            v[i][j] = val;
        }
        for (int i = Y - 1, j = X + 1; i >= 0 && j < 8; i--, j++) {
            v[i][j] = val;
        }
        for (int i = Y + 1, j = X - 1; i < 8 && j >= 0; i++, j--) {
            v[i][j] = val;
        }
    }

    v[Y][X] = type;
}

bool valid(int X, int Y, int T) {
    if (T == 1) return 1;
    for (int i = Y + 1, j = X + 1; i < 8 && j < 8; i++, j++) {
        if (v[i][j] > 1) return 0;
    }
    for (int i = Y - 1, j = X - 1; i >= 0 && j >= 0; i--, j--) {
        if (v[i][j] > 1) return 0;
    }
    for (int i = Y - 1, j = X + 1; i >= 0 && j < 8; i--, j++) {
        if (v[i][j] > 1) return 0;
    }
    for (int i = Y + 1, j = X - 1; i < 8 && j >= 0; i++, j--) {
        if (v[i][j] > 1) return 0;
    }
    return 1;
}

int main() {
    cin.tie(0), ios::sync_with_stdio(0);

    int N;
    cin >> N;
    for (int tc = 1; tc <= N; tc++) {
        int T, X, Y;
        cin >> T >> Y >> X;
        X--; Y--;
        
        if (T == 3) {
            setvals(X, Y, 0, v[Y][X] == 3, 0);
            for (int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                    if (v[i][j] > 1) {
                        setvals(j, i, v[i][j], v[i][j] == 3, 1);
                    }
                }
            }
            cout << "-\n";
            continue;
        }

        if (v[Y][X] || !valid(X, Y, T)) {
            cout << "NEM\n";
            continue;
        }

        setvals(X, Y, T + 1, T == 2, 1);
        cout << "IGEN\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms2100 KiB
2Accepted0/03ms2340 KiB
3Accepted2/23ms2476 KiB
4Accepted2/22ms2372 KiB
5Accepted3/33ms2500 KiB
6Accepted3/33ms2572 KiB
7Accepted5/53ms2792 KiB
8Accepted6/63ms2740 KiB
9Accepted6/63ms2948 KiB
10Accepted6/63ms3048 KiB
11Accepted6/63ms3064 KiB
12Accepted6/63ms3036 KiB
13Accepted6/63ms2944 KiB
14Accepted6/63ms2940 KiB
15Accepted6/63ms2944 KiB
16Accepted6/63ms3160 KiB
17Accepted6/63ms3140 KiB