Skip to content

Commit 91a4575

Browse files
committed
[add] Shadow of the knight medium
1 parent 498aa18 commit 91a4575

File tree

5 files changed

+189
-0
lines changed

5 files changed

+189
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
fscanf(STDIN, "%d %d",
4+
$W, // width of the building.
5+
$H // height of the building.
6+
);
7+
fscanf(STDIN, "%d",
8+
$N // maximum number of turns before game over.
9+
);
10+
fscanf(STDIN, "%d %d",
11+
$X,
12+
$Y
13+
);
14+
15+
$minH = 0; $maxH = $H - 1; $minW = 0; $maxW = $W - 1;
16+
17+
// game loop
18+
while (TRUE) {
19+
fscanf(STDIN, "%s",
20+
$bombDir // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
21+
);
22+
23+
foreach(str_split($bombDir) as $c) {
24+
switch ($c){
25+
case 'L':
26+
$maxW = $X - 1;
27+
break;
28+
case 'R':
29+
$minW = $X + 1;
30+
break;
31+
case 'U':
32+
$maxH = $Y - 1;
33+
break;
34+
case 'D':
35+
$minH = $Y + 1;
36+
break;
37+
}
38+
}
39+
$Y = intval(($minH + $maxH) / 2);
40+
$X = intval(($minW + $maxW) / 2);
41+
// the location of the next window Batman should jump to.
42+
echo("$X $Y\n");
43+
}
44+
?>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import java.util.*;
2+
import java.io.*;
3+
import java.math.*;
4+
5+
class Player {
6+
7+
public static void main(String args[]) {
8+
Scanner in = new Scanner(System.in);
9+
int W = in.nextInt(); // width of the building.
10+
int H = in.nextInt(); // height of the building.
11+
int N = in.nextInt(); // maximum number of turns before game over.
12+
int X = in.nextInt();
13+
int Y = in.nextInt();
14+
15+
int minH = 0, maxH = H - 1, minW = 0, maxW = W - 1;
16+
17+
// game loop
18+
while (true) {
19+
String bombDir = in.next(); // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
20+
for(char c : bombDir.toCharArray()){
21+
switch (c){
22+
case 'L':
23+
maxW = X - 1;
24+
break;
25+
case 'R':
26+
minW = X + 1;
27+
break;
28+
case 'U':
29+
maxH = Y - 1;
30+
break;
31+
case 'D':
32+
minH = Y + 1;
33+
break;
34+
}
35+
}
36+
Y = (minH + maxH) / 2;
37+
X = (minW + maxW) / 2;
38+
System.out.println(X + " " + Y);
39+
}
40+
}
41+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
let inputs = readline().split(' ');
2+
const W = parseInt(inputs[0]); // width of the building.
3+
const H = parseInt(inputs[1]); // height of the building.
4+
const N = parseInt(readline()); // maximum number of turns before game over.
5+
inputs = readline().split(' ');
6+
let X = parseInt(inputs[0]);
7+
let Y = parseInt(inputs[1]);
8+
9+
let minH = 0, maxH = H - 1, minW = 0, maxW = W - 1;
10+
11+
// game loop
12+
while (true) {
13+
let bombDir = readline(); // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
14+
for(let c of bombDir) {
15+
switch (c){
16+
case 'L':
17+
maxW = X - 1;
18+
break;
19+
case 'R':
20+
minW = X + 1;
21+
break;
22+
case 'U':
23+
maxH = Y - 1;
24+
break;
25+
case 'D':
26+
minH = Y + 1;
27+
break;
28+
}
29+
}
30+
Y = Math.ceil((minH + maxH) / 2);
31+
X = Math.ceil((minW + maxW) / 2);
32+
33+
// the location of the next window Batman should jump to.
34+
print(X, Y);
35+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import sys
2+
import math
3+
4+
# Auto-generated code below aims at helping you parse
5+
# the standard input according to the problem statement.
6+
7+
# w: width of the building.
8+
# h: height of the building.
9+
W, H = [int(i) for i in raw_input().split()]
10+
n = int(raw_input()) # maximum number of turns before game over.
11+
X, Y = [int(i) for i in raw_input().split()]
12+
13+
minH = 0
14+
maxH = H - 1
15+
minW = 0
16+
maxW = W - 1
17+
18+
# game loop
19+
while True:
20+
bomb_dir = raw_input() # the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
21+
22+
for c in bomb_dir:
23+
if c == 'L':
24+
maxW = X - 1
25+
elif c == 'R':
26+
minW = X + 1
27+
elif c == 'U':
28+
maxH = Y - 1
29+
elif c == 'D':
30+
minH = Y + 1
31+
32+
Y = int((minH + maxH) / 2)
33+
X = int((minW + maxW) / 2)
34+
35+
# the location of the next window Batman should jump to.
36+
print X, Y
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sys
2+
import math
3+
4+
# w: width of the building.
5+
# h: height of the building.
6+
W, H = [int(i) for i in input().split()]
7+
n = int(input()) # maximum number of turns before game over.
8+
X, Y = [int(i) for i in input().split()]
9+
10+
minH = 0
11+
maxH = H - 1
12+
minW = 0
13+
maxW = W - 1
14+
15+
# game loop
16+
while True:
17+
bomb_dir = input() # the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)
18+
19+
for c in bomb_dir:
20+
if c == 'L':
21+
maxW = X - 1
22+
elif c == 'R':
23+
minW = X + 1
24+
elif c == 'U':
25+
maxH = Y - 1
26+
elif c == 'D':
27+
minH = Y + 1
28+
29+
Y = int((minH + maxH) / 2)
30+
X = int((minW + maxW) / 2)
31+
32+
# the location of the next window Batman should jump to.
33+
print(X, Y)

0 commit comments

Comments
 (0)