[UVA] 11760 - Brother Arif, Please feed us!@Morris' Blog|PChome Online 人新台
2013-06-24 15:43:42| 人1,139| 回0 | 上一篇 | 下一篇

[UVA] 11760 - Brother Arif, Please feed us!

0 收藏 0 0 站台

I

Brother Arif, please feed us!

 

Brother Arif is a great problemsetter. He loves grid. Also, he loves light. That's why the other problemsetters believe that asking him to throw a feast is always right. Unfortunately Brother Arif himself doesn't think so. Instead of all the naggings and reasons going on around him, he stays in his chair with dreamy eyes and lovingly thinks about newer ways of placing lights inside a 2D grid. Now, it's time to make your stand for the deprived problemsetters' right and force Brother Arif to their pleas.

Now, the problemsetters have all gathered inside a room. The floor of this room is shaped like a 2d Rectangular grid consisting of many cells. Any of the problemsetters can stand on a cell. A cell has enough place for only one people and everyone must occupy exactly one cell at a time. Brother Arif, standing on one of these cells, can move to one of the four adjacent cells just once or he may not move at all. He may not leave the grid, however. The other problemsetters are standing  on other cells. With the help of their new telecatching device, they can capture anyone standing at the same row or column irrespective to his distance. So, now you are given the positions of the problemsetters and are asked to figure out if Brother Arif can escape from getting captured (and thus throwing a huge party.)

Input

The input file has multiple test cases. Each test case begins with 3 integers, R (1<=R<=10000), C (1<=C<=10000) & N (1<=N<=2000). R &C are the number of rows & columns in the grid while N denotes the number of problemsetters present on the room. N + 1 lines follow the first line. Each of the next N lies has 2 integers, r (0 <= r < R) & c (0 <= c < C) , position of a problemsetter. For your reference, the upper left corner of the cell has (0,0) while the lower left one has (R-1, 0) and the lower right one has (R-1, C-1) co-ordinate. The last line gives the co-ordinate of Brother Arif in the same format. The last test case will be followed by a case with R = C = N = 0. This case should not be processed.

Output

For each test case, print a line. This line starts like, “Case X: “, where, X is the case number. After that print a string based on Brother Arif's destiny. If Brother Arif can find a cell where none else can catch him, print “Escaped again! More 2D grid problems!”. If someone can capture him no matter in which cell he goes, print “Party time! Let's find a restaurant!”

Sample Input

Sample Output

5 5 2
0 1
4 2
1 2
5 5 3
0 1
4 2
4 3
1 2
0 0 0

Case 1: Escaped again! More 2D grid problems!
Case 2: Party time! Let's find a restaurant!

Problem Setter: Mohammad Mahmudur Rahman, Special Thanks: Sohel Hafiz

 



查目的即可。

只能上下左右移一步,有有可以走的位置。
不能走的位置被定可以被其他人得行列重。

#include <stdio.h>
#include <string.h>
using namespace std;
int col[10005], row[10005];
int r, c;
int check(int x, int y) {
    if(x < 0 || y < 0 || x >= r || y >= c)
        return 1;
    return row[x]|col[y];
}
int main() {
    int cases = 0;
    int x, y, n, i;
    while(scanf("%d %d %d", &r, &c, &n) == 3) {
        if(r == 0)  break;
        memset(row, 0, sizeof(row));
        memset(col, 0, sizeof(col));
        for(i = 0; i < n; i++) {
            scanf("%d %d", &x, &y);
            row[x] = col[y] = 1;
        }
        scanf("%d %d", &x, &y);
        int flag = !check(x, y);
        flag |= !check(x+1, y);
        flag |= !check(x-1, y);
        flag |= !check(x, y+1);
        flag |= !check(x, y-1);
        printf("Case %d: ", ++cases);
        if(flag)
            puts("Escaped again! More 2D grid problems!");
        else
            puts("Party time! Let's find a restaurant!");

    }
    return 0;
}

台: Morris
人(1,139) | 回(0)| 推 (0)| 收藏 (0)|
全站分: 不分 | 人分: UVA |
此分下一篇:[UVA] 1241 - Jollybee Tournament
此分上一篇:[UVA][循] 11701 - Cantor

是 (若未登入"人新台"看不到回覆唷!)
* 入:
入片中算式的果(可能0) 
(有*必填)
TOP
全文
ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86