// UVa 11760 - Brother Arif, Please feed us!
import java.util.Scanner;
public class Main {
public static boolean[] row, col;
public static int[][] move = { { 0, 0 }, { 0, 1 }, { 0, -1 }, { -1, 0 },
{ 1, 0 } };
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
try {
int t = 0;
while (true) {
t++;
int r = scanner.nextInt();
int c = scanner.nextInt();
int n = scanner.nextInt();
if (r == 0 && c == 0 && n == 0)
break;
row = new boolean[r];
col = new boolean[c];
for (int i = 0; i < n; i++) {
int pr = scanner.nextInt();
int pc = scanner.nextInt();
row[pr] = true;
col[pc] = true;
}
int ar = scanner.nextInt();
int ac = scanner.nextInt();
boolean possible = false;
for (int i = 0; i < 5; i++) {
int rr = ar + move[i][0];
int cc = ac + move[i][1];
if (rr >= 0 && rr < r && cc >= 0 && cc < c
&& row[rr] == false && col[cc] == false) {
possible = true;
break;
}
}
if (possible)
System.out.println("Case " + t
+ ": Escaped again! More 2D grid problems!");
else
System.out.println("Case " + t
+ ": Party time! Let's find a restaurant!");
}
} finally {
scanner.close();
}
}
}
Monday, May 4, 2015
UVa 11760 - Brother Arif, Please feed us!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment