This one is pretty strange (or at least I can't figure out what triggers it). I have the piece of code below, but there seems to be a bug with the second call of scanf
. It simply gets skipped. So the input should be something like
10 3
fbfbfbfbfb
3 1 2 3
3 4 5 6
4 7 8 9 10
but after I enter
10 3
fbfbfbfbfb
I get the (wrong) result, I do not get asked for the other 3 lines. Thanks in advance!
P.S.: The variables' names are not in English :)
#include <stdio.h>
#define N 200
int main(void) {
unsigned short n, k, i, j, elevi_grupa, elev_curent,
fete = 0, baieti = 0, corect = 1;
int sir[N];
scanf("%hu %hu", &n, &k);
for(i = 0; i < n; ++i)
sir[i] = getchar();
for(i = 0; i < k; ++i) {
scanf("%hu", &elevi_grupa);
if(elevi_grupa < n % k || elevi_grupa > n % k + 1)
corect = 0;
for(j = 0; j < elevi_grupa; ++j) {
scanf("%hu", &elev_curent);
if(sir[elev_curent - 1] == 'f')
++fete;
else
++baieti;
}
if(fete - baieti < -1 || fete - baieti > 1)
corect = 0;
printf("%hu %hu\n", baieti, fete);
fete = 0;
baieti = 0;
}
if(corect)
printf("DA");
else
printf("NU");
return 0;
}