summaryrefslogtreecommitdiffstats
path: root/inf/zotksd/1.c
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-04-06 22:22:40 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2023-04-06 22:22:40 +0200
commitc5fd0c67e79d56c5f09ff8587101917a0c45120c (patch)
tree438484adefdebb158baf3bb8756a27dffedc7d4a /inf/zotksd/1.c
parentmat zadnji test, upam (diff)
parentz: zotksd, fizvaje10, infsemin (diff)
downloadsola-gimb-4-c5fd0c67e79d56c5f09ff8587101917a0c45120c.tar
sola-gimb-4-c5fd0c67e79d56c5f09ff8587101917a0c45120c.tar.gz
sola-gimb-4-c5fd0c67e79d56c5f09ff8587101917a0c45120c.tar.bz2
sola-gimb-4-c5fd0c67e79d56c5f09ff8587101917a0c45120c.tar.lz
sola-gimb-4-c5fd0c67e79d56c5f09ff8587101917a0c45120c.tar.xz
sola-gimb-4-c5fd0c67e79d56c5f09ff8587101917a0c45120c.tar.zst
sola-gimb-4-c5fd0c67e79d56c5f09ff8587101917a0c45120c.zip
Diffstat (limited to 'inf/zotksd/1.c')
-rw-r--r--inf/zotksd/1.c57
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;
+}