/* * Sample solution to the Polygon problem. * Central Europe Regional Contest 2007. * * Jan Cibulka, 2007 */ #include #include #include #define MAXN 1000 int n; typedef struct Point { int x,y,orig,even; int wheresx, wheresy; } Point; Point pt[MAXN+2]; Point ptsx[MAXN+2]; Point ptsy[MAXN+2]; char dirc[MAXN+2]; int dirccnt; int possx, possy; int ptsx_cmp(const void *e1, const void *e2) { Point *p1 = (Point *)e1; Point *p2 = (Point *)e2; if(p1->x!=p2->x) return p1->x - p2->x; else return p1->y - p2->y; } int ptsy_cmp(const void *e1, const void *e2) { Point *p1 = (Point *)e1; Point *p2 = (Point *)e2; if(p1->y!=p2->y) return p1->y - p2->y; else return p1->x - p2->x; } void go_next(int dir) { if(dir==0) { dirc[dirccnt++] = 'N'; possx = possx+1; possy = pt[ptsx[possx].orig].wheresy; } if(dir==1) { dirc[dirccnt++] = 'E'; possy = possy+1; possx = pt[ptsy[possy].orig].wheresx; } if(dir==2) { dirc[dirccnt++] = 'S'; possx = possx-1; possy = pt[ptsx[possx].orig].wheresy; } if(dir==3) { dirc[dirccnt++] = 'W'; possy = possy-1; possx = pt[ptsy[possy].orig].wheresx; } } int main(void) { int i,j,tmp,begprint; int lastdir; while(1) { n=-1; scanf(" %d ", &n); if(n==0) break; assert(n<=MAXN && n>0); for(i=0;i