#include<iostream>
#include "message.h"
#include "dzialka.h"
using namespace std;
int main(){
int n,m;
n = GetFieldHeight();
m = GetFieldWidth();
long long suma=0;
int petla=0;
for(int h=0; h<n; h+=NumberOfNodes()){
for(int i = 0; i < m; i++){
int pozycja=n;
for(int j = i; j < m; j++){
for(int k=MyNodeId() + petla*NumberOfNodes(); k<pozycja; k++){
int pole;
pole = IsUsableCell(k, j);
if(pole==1){
suma++;
}else{
pozycja = k;
}
}
if(pozycja==petla){
j = m;
}
}
}
petla++;
}
if (MyNodeId() > 0) {
PutLL(0, suma);
Send(0);
} else {
for (int instancja = 1; instancja < NumberOfNodes(); ++instancja) {
Receive(instancja);
suma += GetLL(instancja);
}
cout << suma;
}
}
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 44 45 46 | #include<iostream> #include "message.h" #include "dzialka.h" using namespace std; int main(){ int n,m; n = GetFieldHeight(); m = GetFieldWidth(); long long suma=0; int petla=0; for(int h=0; h<n; h+=NumberOfNodes()){ for(int i = 0; i < m; i++){ int pozycja=n; for(int j = i; j < m; j++){ for(int k=MyNodeId() + petla*NumberOfNodes(); k<pozycja; k++){ int pole; pole = IsUsableCell(k, j); if(pole==1){ suma++; }else{ pozycja = k; } } if(pozycja==petla){ j = m; } } } petla++; } if (MyNodeId() > 0) { PutLL(0, suma); Send(0); } else { for (int instancja = 1; instancja < NumberOfNodes(); ++instancja) { Receive(instancja); suma += GetLL(instancja); } cout << suma; } } |
English