127432024-12-29 16:57:19sarminÜtős helyzet (75 pont)cpp17Hibás válasz 33/754ms568 KiB
#include <bits/stdc++.h>
using namespace std;

pair<int, vector<vector<pair<int, int>>>> change(vector<vector<pair<int, int>>> v, int x, int y, int t, int plus) {
	v[x][y].second += plus;
	for (int i = 0; i < 8; i++) {
		if (i == y) continue;
		if (v[x][i].first != 0) {
			return {false, v};
		}
		v[x][i].second += plus;
	}
	for (int i = 0; i < 8; i++) {
		if (i == x) continue;
		if (v[i][y].first != 0) {
			return {false, v};
		}
		v[i][y].second += plus;
	}
	if (t == 1) {
		// bastion
		return {true, v};
	}
	int nX = x, nY = y;
	nX++; nY++;
	while (nX >= 0 && nX < 8 && nY >= 0 && nY < 8) {
		if (v[nX][nY].first != 0) {
			return {false, v};
		}
		v[nX][nY].second += plus;
		nX++; nY++;
	}
	nX = x; nY = y;
	nX--; nY--;
	while (nX >= 0 && nX < 8 && nY >= 0 && nY < 8) {
		if (v[nX][nY].first != 0)  {
			return {false, v};
		}
		v[nX][nY].second += plus;
		nX--; nY--;
	}
	nX = x; nY = y;
	nX++; nY--;
	while (nX >= 0 && nX < 8 && nY >= 0 && nY < 8) {
		if (v[nX][nY].first != 0) {
			return {false, v};
		}
		v[nX][nY].second += plus;
		nX++; nY--;
	}
	nX = x; nY = y;
	nX--; nY++;
	while (nX >= 0 && nX < 8 && nY >= 0 && nY < 8) {
		if (v[nX][nY].first != 0) {
			return {false, v};
		}
		v[nX][nY].second += plus;
		nX--; nY++;
	}
	return {true, v};
}

int main() {

	int n; cin >> n;
	vector<vector<pair<int, int>>> v(8, vector<pair<int, int>>(8, {0, 0}));
	// {type, num_of_intersects}
	for (int i = 0; i < n; i++) {
		int t, x, y; cin >> t >> x >> y;
		x--; y--;
		if (t != 3 && v[x][y].first != 0) {
			cout << "NEM\n";
			continue;
		}
		if (t != 3) {
			auto s = change(v, x, y, t, +1);
			if (s.first == true) {
				v = s.second;
				v[x][y].first = t;
				cout << "IGEN\n";
			} else {
				cout << "NEM\n";
			}
		} else {
			auto s = change(v, x, y, t, -1);
			v = s.second;
			v[x][y].first = 0;
			cout << "-\n";
		}
	}
	
	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base33/75
1Elfogadva0/01ms320 KiB
2Elfogadva0/04ms508 KiB
3Elfogadva2/21ms320 KiB
4Elfogadva2/21ms508 KiB
5Elfogadva3/31ms320 KiB
6Elfogadva3/34ms320 KiB
7Elfogadva5/53ms320 KiB
8Hibás válasz0/64ms320 KiB
9Hibás válasz0/63ms320 KiB
10Hibás válasz0/64ms320 KiB
11Hibás válasz0/64ms364 KiB
12Hibás válasz0/63ms320 KiB
13Hibás válasz0/63ms320 KiB
14Hibás válasz0/64ms320 KiB
15Elfogadva6/64ms320 KiB
16Elfogadva6/64ms320 KiB
17Elfogadva6/63ms568 KiB