Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int n;
- char s1[30][100];
- char s2[30][100];
- int i, j;
- int main() {
- scanf("%d", &n);
- if (n&1) /* always bad if number of students is odd */
- goto bad;
- for (i = 0; i < n; i++)
- scanf("%s", s1[i]);
- for (i = 0; i < n; i++) {
- scanf("%s", s2[i]);
- if (!strcmp(s1[i], s2[i])) /* can't be partnered with self */
- goto bad;
- }
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++)
- if (!strcmp(s1[i], s2[j]) && !strcmp(s1[j], s2[i]))
- break;
- if (j == n) /* partners arranged inconsistently */
- goto bad;
- }
- printf("good\n");
- return 0;
- bad:
- printf("bad\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement