Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <algorithm>
- #include <queue>
- #include <vector>
- #include <numeric>
- #include <iomanip>
- #include <utility>
- using namespace std;
- char Tabuleiro[2][501][501];
- //char Tabuleiro2[501][501];
- int main()
- {
- long int N, P;
- cin >> N >> P;
- for (int i = 0; i < P; i++) {
- int L, C;
- cin >> L >> C;
- Tabuleiro[0][L][C] = 'P';
- }
- for (int i = 0; i < P; i++) {
- int L, C;
- cin >> L >> C;
- Tabuleiro[0][L][C] = 'B';
- }
- int subareasP = P;
- int subareasB = P;
- // Pra cada tamanho de quadrado
- for (int n = 1; n <= N; n++)
- {
- int tab = 1 -( n % 2);
- for (int k = 0; k <= N; k++)
- {
- for (int l = 0; l <= N; l++)
- {
- Tabuleiro[1 - tab][k][l] = '-';
- }
- }
- // Pra cada posicao desse quadrado no tabuleiro
- for (int i = 1; i < N - n + 1; i++)
- {
- for (int j = 1; j < N - n + 1; j++)
- {
- char subsquare1 = Tabuleiro[tab][i][j];
- char subsquare2 = Tabuleiro[tab][i + 1][j];
- char subsquare3 = Tabuleiro[tab][i][j + 1];
- char subsquare4 = Tabuleiro[tab][i + 1][j + 1];
- bool temPreto, temBranco, temX;
- temPreto = subsquare1 == 'P' || subsquare2 == 'P' || subsquare3 == 'P' || subsquare4 == 'P';
- temBranco = subsquare1 == 'B' || subsquare2 == 'B' || subsquare3 == 'B' || subsquare4 == 'B';
- temX = subsquare1 == 'X' || subsquare2 == 'X' || subsquare3 == 'X' || subsquare4 == 'X';
- if (temPreto && !temBranco && !temX)
- {
- Tabuleiro[1-tab][i][j] = 'P';
- subareasP++;
- }
- else if (!temPreto && temBranco && !temX)
- {
- Tabuleiro[1-tab][i][j] = 'B';
- subareasB++;
- }
- else if (temPreto && temBranco)
- {
- Tabuleiro[1 - tab][i][j] = 'X';
- }
- else
- {
- Tabuleiro[1-tab][i][j] = '-';
- }
- }
- }
- }
- cout << subareasP << " " << subareasB << endl;
- int i;
- cin >> i;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement