| Krofna (277) | ||||
The problem I am trying to solve is following (poor translation in 3..2..)
Idea behind my solution was following: 1) Pick the room which will cause lowest number of other rooms to be affected by noise and put a klingon in it. 2) Repeat 1) untill all rooms are affected by noise Problem is: Works only on some inputs. Sample I/O: I: 5 5 2, O: 6 I: 4 7 3, O: 5 I: 5 7 1, O: 18 What did I do wrong?
| ||||
|
|
||||
| Sandermatt (17) | |
| I am not sure how others see it, but for me it would help if you could translate the words: Boja, BIJELA , SIVA, CRNA, Rasporedi, NapraviBuku, IzracunajCijene, Cijena . | |
|
|
|
| Program Programmer (39) | |
|
i will: Boja = Color BIJELA = White SIVA = Grey CRNA = Black Rasporedi = Arange (i dont know if i translated that quite right) NapraviBuku = MakeNoise IzracunajCijene = CalculatePrices Cijena = Price | |
|
|
|
| Krofna (277) | |
|
That is correct, Program Programmer. Also: pIzvor = pSource , pTrenutna = pCurrent , Udaljenost = Manhattan Distance (Altho these are obvious from the context) | |
|
|
|
| Sandermatt (17) | |
|
I would say look at: int Hotel::Cijena(Node* pNode) { int Cijena = 0; for (int y = pNode->P.y - B; y < pNode->P.y + B; ++y) for (int x = pNode->P.x - B; x < pNode->P.x + B; ++x) if (x >= 0 && y >= 0 && x < X && y < Y) if (G[y][x].B != CRNA) ++Cijena; //cout << pNode->P.x << " " << pNode->P.y << " " << Cijena << "\n"; return Cijena; } In the for loops you need a smaller or equal than sign instead of an equal sign. int Hotel::Cijena(Node* pNode) { int Cijena = 0; for (int y = pNode->P.y - B; y <= pNode->P.y + B; ++y) for (int x = pNode->P.x - B; x <= pNode->P.x + B; ++x) if (x >= 0 && y >= 0 && x < X && y < Y) if (G[y][x].B != CRNA) ++Cijena; //cout << pNode->P.x << " " << pNode->P.y << " " << Cijena << "\n"; return Cijena; } | |
|
|
|