#include "dzialka.h"
#include "message.h"
#include<bits/stdc++.h>
using namespace std;
bool tab[105][105];
int pref[105][105];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int a=GetFieldHeight(),b=GetFieldWidth();
long long licz=0;
for(int x=1;x<=a;x++)
for(int y=1;y<=b;y++)
{
tab[x][y]=IsUsableCell(x,y);
pref[x][y]=pref[x-1][y]+pref[x][y-1]-pref[x-1][y-1]+tab[x][y];
}
for(int x=1+MyNodeId();x<=a;x+=NumberOfNodes())
for(int y=1;y<=b;y++)
{
for(int p=1;p<=x;p++)
for(int q=1;q<=y;q++)
if(pref[x][y]+pref[p-1][q-1]-pref[x][q-1]-pref[p-1][y]==(x-p+1)*(y-q+1))
licz++;
}
if (MyNodeId() > 0)
{
PutLL(0,licz);
Send(0);
}
else
{ // MyNodeId == 0
for (int instancja = 1; instancja < NumberOfNodes(); ++instancja)
{
Receive(instancja);
licz += GetLL(instancja);
}
cout << licz << '\n';
}
return 0;
}
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 37 38 39 40 41 42 43 | #include "dzialka.h" #include "message.h" #include<bits/stdc++.h> using namespace std; bool tab[105][105]; int pref[105][105]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int a=GetFieldHeight(),b=GetFieldWidth(); long long licz=0; for(int x=1;x<=a;x++) for(int y=1;y<=b;y++) { tab[x][y]=IsUsableCell(x,y); pref[x][y]=pref[x-1][y]+pref[x][y-1]-pref[x-1][y-1]+tab[x][y]; } for(int x=1+MyNodeId();x<=a;x+=NumberOfNodes()) for(int y=1;y<=b;y++) { for(int p=1;p<=x;p++) for(int q=1;q<=y;q++) if(pref[x][y]+pref[p-1][q-1]-pref[x][q-1]-pref[p-1][y]==(x-p+1)*(y-q+1)) licz++; } if (MyNodeId() > 0) { PutLL(0,licz); Send(0); } else { // MyNodeId == 0 for (int instancja = 1; instancja < NumberOfNodes(); ++instancja) { Receive(instancja); licz += GetLL(instancja); } cout << licz << '\n'; } return 0; } |
English