/* ACM North Central Region, 1994-95 Problem E, Processing MX Records Ed Karrels, May 1996 */ #include #include typedef struct { char from[80], to[80]; int pri, up; } MX; void Read(MX *mx) { static char from[80]; char c; scanf("%*[^\n]"); c = getchar(); /* newline */ c = getchar(); /* first character, next line */ if (isspace(c)) { strcpy(mx->from, from); scanf("%d %s", &mx->pri, mx->to); } else { ungetc(c, stdin); scanf("%s %d %s", from, &mx->pri, mx->to); strcpy(mx->from, from); } mx->up = 1; } int Match(char *s1, char *s2) { if (!strcmp(s1, s2)) return 1; if (s2[0] == '*') { s2++; s1 += strlen(s1) - strlen(s2); if (!strcmp(s1, s2)) return 1; } return 0; } int main() { int n, i, best_i, best_pri; MX *mx; char cmd, addr[80]; scanf("%d", &n); mx = (MX*)malloc(sizeof(MX) * n); for (i=0; i %s\n", addr, (best_i==-1) ? "" : mx[best_i].to); break; case 'D': for (i=0; i