Had a good sleep and when woke up, I finally saw the solution.
For example, when the building has width 4, Batman only needs 3 steps to go from left to right.
The moving area is smaller than the W and H of the building.
Now I can get 100% pass without relying on luck.
in level tour it does not gives it does not give direction bombdir in c++ compiler. in java c ok
I have problem with TC6 (Evasive) - no sense there for me.
Final results for me is:
Batman moved from window (0,2) to window (0,1)
The bombs are located above Batman
Or:
Batman moved from window (0,2) to window (0,0)
The bombs are located below Batman
Where is the bomb?
Can anybody help me? I canāt go through validation tests āCorrect cuttingā.
What algo do you use? Is it binary search? If yes, then pay attention to the rounding.
Thanks for help. Itās working!
I donāt see the test list in the IDE, how to fix this? (for all puzzles, tested different browsers, some setting Iām missing?)
See the image:
Thx a lot!
the ultimate level
Weāll look into it.
EDIT: Fixed!
Hi i have a small bug. When i test tower for example i begin at 0,1 debug say that the bomb is down so i go in 0,40 and it say down so my program searching between 40 and 60 but bomb is on 0,36.
Sorry for my bad english.
I pass all tests except Tower. Itās because of rounding but my question is how do I know which way I need to round (up or down)? Iāve tried the following:
- always round up with this I fail the validator in the IDE
- always round down with this I fail the validator when I submit
- round towards the direction needed to go, I fail āEvasiveā and āNot There?ā
Iām just not sure how I would know which way I need to round
I solved it by rounding up when the condition calls for you to go up or left.
When i submit it loads for a long time but it still doesnt give a result but for the test cases that are shown it runs perfectly fine. Also for my report it doesnt show anything
Seems it was a temporary issue since you validated the puzzle. Let me know if it reoccurs.
i am using python and this is the code
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
# w: width of the building.
# h: height of the building.
w, h = [int(i) for i in raw_input().split()]
n = int(raw_input()) # maximum number of turns before game over.
x0, y0 = [int(i) for i in raw_input().split()]
# game loop
while True:
bomb_dir = raw_input() # the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
if bomb_dir == 'U':
print str(x0 ) + ' ' + str(y0 - 1)
elif bomb_dir == 'UR':
print str(x0 + 1) + ' ' + str(y0 - 1)
elif bomb_dir == 'R':
print str(x0 + 1) + ' ' + str(y0)
elif bomb_dir == 'DR':
print str(x0 + 1) + ' ' + str(y0 + 1)
elif bomb_dir == 'D':
print str(x0 ) + ' ' + str(y0 + 1)
elif bomb_dir == 'DL':
print str(x0 - 1) + ' ' + str(y0 + 1)
elif bomb_dir == 'L':
print str(x0 - 1) + ' ' + str(y0)
elif bomb_dir == 'UL':
print str(x0 - 1) + ' ' + str(y0 - 1)
why is the āDā part in the code not working? it goes back and forth, back and forth forever
Since you never modify x0 nor y0, Batman cannot go far.
hello everyone, i have finished the code in C++ and there is no syntax errors but " batman" never even moved.
this message appears in console input āTimeout: your program did not provide an input in due timeā.
but i canāt detect error in my code, can any one help ?
Hi, Im lost here. Used all optimalizations I could find, but still missing 1 step by 1 field on last 2 checks.
Im using binarysearch with ceil of (max-current)/2 . Also working with limiting limits after each move by 1. And that Batman always move for at least 1 field if hes missing in that dirrection. Its basically all I could think of and what I found on this forum. Yet still missing some pieceā¦ Using Java.
My code:
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int W = in.nextInt(); // width of the building.
int H = in.nextInt(); // height of the building.
int N = in.nextInt(); // maximum number of turns before game over.
int X0 = in.nextInt();
int Y0 = in.nextInt();
// game loop
int nextX = X0;
int nextY = Y0;
int minW = 0;
int minH = 0;
int maxW = W;
int maxH = H;
int modifierXright = 2, modifierXleft = 2, modifierYdown = 2, modifierYup = 2,modifier = 2;
while (true) {
String bombDir = in.next();
modifierXright = newModifier(nextX,maxW);
if(modifierXright == 0) modifierXright = 1;
modifierXleft = newModifier(nextX,minW);
if(modifierXleft == 0) modifierXleft = -1;
modifierYdown = newModifier(nextY,maxH);
if(modifierYdown == 0) modifierYdown = 1;
modifierYup = newModifier(nextY,minH);
if(modifierYup == 0) modifierYup = -1;
System.err.println("modifierXright= "+modifierXright+" modifierXleft= "+modifierXleft+
" modifierYdown= "+modifierYdown + " modifierYup= " + modifierYup +
"\nminW= "+minW+" maxW= "+maxW+" minH= "+minH+" maxH= "+maxH);
switch(bombDir) {
case "U": {
maxH = nextY-1;
nextY+=modifierYup;
}break;
case "UR": {
maxH = nextY-1; minW = nextX+1;
nextX+=modifierXright;nextY+=modifierYup;
}break;
case "R":{
minW = nextX+1;
nextX+=modifierXright;
}break;
case "DR": {
minH = nextY+1; minW = nextX+1;
nextX+=modifierXright;nextY+=modifierYdown;
}break;
case "D": {
minH = nextY+1;
nextY+=modifierYdown;
};break;
case "DL": {
minH = nextY+1; maxW = nextX-1;
nextX+=modifierXleft;nextY+=modifierYdown;
}break;
case "L": {
maxW = nextX-1;
nextX+=modifierXleft;
}break;
case "UL": {
maxH = nextY-1; maxW = nextY-1;
nextX+=modifierXleft;nextY+=modifierYup;
}break;
}
System.out.println(nextX+" "+nextY);
}
}
private static int newModifier(float currentPos, float maxPos) {
return (int)(Math.ceil((maxPos-currentPos)/2.0));
}
Everything works fine, but last challenge just shows that: Timeout: your program did not provide input in due time.
Edit 1: LOL, Because the map is too large for some calculations it canāt answer fast enough.
I can seem to get my if statements to trigger. Can anyone help me out or explain why?
Iām kinda new to coding and this site, could someone please tell me the solution or at least help me with what i have to do?