//Dzialki 2 - nie rozprosz #include "dzialka.h" #include "message.h" #include <stack> #include <vector> #include <iostream> using namespace std; bool isSquare(int x1, int y1, int x2, int y2){ for(int i = x1; i <= x2; i++){ for(int j = y1; j <= y2; j++) if (!IsUsableCell(i, j)) return false; } return true; } int main() { if (MyNodeId() > 0) return 0; unsigned long long liczbaSpos = 0; const int liczbaWierszy = GetFieldHeight(); const int liczbaKolumn = GetFieldWidth(); for(int i = 0; i < liczbaWierszy; i++) for(int j = 0; j < liczbaKolumn; j++) for(int x = i; x < liczbaWierszy; x++) for(int y = j; y < liczbaWierszy; y++) if (isSquare(i, j, x, y)) liczbaSpos++; cout << liczbaSpos << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | //Dzialki 2 - nie rozprosz #include "dzialka.h" #include "message.h" #include <stack> #include <vector> #include <iostream> using namespace std; bool isSquare(int x1, int y1, int x2, int y2){ for(int i = x1; i <= x2; i++){ for(int j = y1; j <= y2; j++) if (!IsUsableCell(i, j)) return false; } return true; } int main() { if (MyNodeId() > 0) return 0; unsigned long long liczbaSpos = 0; const int liczbaWierszy = GetFieldHeight(); const int liczbaKolumn = GetFieldWidth(); for(int i = 0; i < liczbaWierszy; i++) for(int j = 0; j < liczbaKolumn; j++) for(int x = i; x < liczbaWierszy; x++) for(int y = j; y < liczbaWierszy; y++) if (isSquare(i, j, x, y)) liczbaSpos++; cout << liczbaSpos << endl; } |