|
|
вернуться в форумI got AC with incorrect code! (+) Послано qwerty 28 июл 2005 21:07 Here it is my code! #include <stdio.h> #define N 100 #define G 10 #define Y 20 char a[N][N] = {0}, n, b[N] = {0}; int main() { int i, j, k, t;
scanf("%d", &n); for (i = 0; i < n; ++i) { scanf("%d", &k); for (j = 0; j < k; ++j) { scanf("%d", &t); a[i][t-1] = 1; } }
for (i = 1; i < n; ++i) {
for (j = 0; j < i; ++j) if (a[i][j] == 1) { if (b[j] < 0) { b[i]--; b[j]++; a[i][j] = Y; a[j][i] = G; } if (b[j] > 0) { b[i]++; b[j]--; a[i][j] = G; a[j][i] = Y; } }
for (j = 0; j < i; ++j) if (a[i][j] == 1) { if (b[i] >= 0) { b[i]--; b[j]++; a[i][j] = Y; a[j][i] = G; continue; } if (b[i] < 0) { b[i]++; b[j]--; a[i][j] = G; a[j][i] = Y; continue; } } } for (i = 0; i < n; ++i) { for (j = 0; j < n; ++j) if (a[i][j] == G) printf("G "); else if (a[i][j] == Y) printf("Y "); printf("\n"); } return 0; } And here it is tricky test: 6 1 4 2 4 6 1 5 4 1 2 5 6 2 3 4 2 2 4 AC 15 lines my AC 15 lines on PASCAL 0.001s 131 КБ |
|
|