I can't find any test cases that make this fail, but am still getting WA, any ideas?
Code: Select all
#include <stdio.h>
int main() {
int mi[120][120];
int mc[120][120];
int s[120];
int c, d, f, g, n, t;
int i, j, k;
scanf(" %d", &n);
g = 1;
while (n != 0) {
if (g > 1) putchar('\n');
for (i = 0; i < n; i++) {
scanf(" %d", &s[i]);
}
scanf(" %d", &t);
for (i = 0; i < n; i++) {
for (j = 0; j < t; j++) {
mc[i][j] = mi[i][j] = 0;
}
}
for (i = 0; i < t; i++) {
scanf("%d", &k);
while (k != 0) {
if (k < 0) {
mi[-k - 1][i]++;
mc[-k - 1][i]--;
} else {
mc[k - 1][i]++;
}
scanf("%d", &k);
}
}
scanf(" %d", &f);
c = 0;
while (c < f) {
d = 0;
for (i = 0; i < t; i++) {
for (j = 0; j < n; j++) {
if (s[j] < mi[j][i]) {
break;
}
}
if (j == n) {
for (j = 0; j < n; j++) {
s[j] += mc[j][i];
}
c++;
d = 1;
if (c == f) goto end;
}
}
if (!d) {
break;
}
}
end:
if (!d) {
printf("Case %d: dead after %d transitions\n", g++, c);
} else {
printf("Case %d: still live after %d transitions\n", g++, c);
}
printf("Places with tokens:");
for (i = 0; i < n; i++) {
if (s[i] > 0) {
printf(" %d (%d)", i + 1, s[i]);
}
}
putchar('\n');
scanf(" %d", &n);
}
return 0;
}
I've tried the set Jan sent, and it got the same answers. I also tried this (appended to Jan's set):
Code: Select all
2
2 0
2
-1 2 2 0
-2 -2 -2 1 0
10
2
2 0
2
-1 2 2 0
-2 -2 -2 1 0
6
expecting:
Code: Select all
Case 7: dead after 6 transitions
Places with tokens: 2 (2)
Case 8: still live after 6 transitions
Places with tokens: 2 (2)
and it worked, but the judge still gives me WA.
Thanks in advance,
Lucas