diff options
Diffstat (limited to '')
-rw-r--r-- | inf/zotksd/1.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/inf/zotksd/1.c b/inf/zotksd/1.c new file mode 100644 index 0000000..7a2de18 --- /dev/null +++ b/inf/zotksd/1.c @@ -0,0 +1,57 @@ +// naloge ne razumem najbolje +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#define S 25000 +int main (void) { + int crke[25]; + char buf[S]; + fgets(buf, S, stdin); + int n = strtol(buf, NULL, 10); + for (int i = 0; i < n; i++) { + int crkecopy[25]; + memcpy(crkecopy, crke, sizeof(crke)); + fgets(buf, S, stdin); + char dodaten = -1; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-compare" + if (strlen(buf) != i+1 && 0) { +#ifndef EVAL + fprintf(stderr, "napačna dolžina niza %s na indeksu %d\n", buf, i); +#endif + printf("%d\n", i); + return 0; + } +#pragma GCC diagnostic pop +#ifndef EVAL + fprintf(stderr, "pri i==%d obdelujem niz %s", i, buf); +#endif + for (int j = 0; j <= i; j++) { + int crka = buf[j]-'A'; + if (--crkecopy[crka] < 0) { + if (dodaten != -1) { + printf("%d\n", i); +#ifndef EVAL + fprintf(stderr, "konec, ker je preveč novih, dodaten je %c\n", dodaten+'A'); +#endif + return 0; + } + dodaten = crka; +#ifndef EVAL + fprintf(stderr, "i==%d, dodaten je sedaj %c\n", i, dodaten+'A'); +#endif + crke[crka]++; + } + } + for (int j = 0; j < 25; j++) + if (crkecopy[j] != 0 && crkecopy[j] != -1) { + printf("%d\n", i); +#ifndef EVAL + fprintf(stderr, "konec, ker ni pobrisal vseh\n"); +#endif + return 0; + } + } + printf("%d\n", n); + return 0; +} |