summaryrefslogtreecommitdiffstats
path: root/inf/zotks/3
diff options
context:
space:
mode:
Diffstat (limited to 'inf/zotks/3')
-rwxr-xr-xinf/zotks/3/a.outbin0 -> 17056 bytes
-rw-r--r--inf/zotks/3/prog.c49
2 files changed, 49 insertions, 0 deletions
diff --git a/inf/zotks/3/a.out b/inf/zotks/3/a.out
new file mode 100755
index 0000000..2b99105
--- /dev/null
+++ b/inf/zotks/3/a.out
Binary files differ
diff --git a/inf/zotks/3/prog.c b/inf/zotks/3/prog.c
new file mode 100644
index 0000000..4b6b551
--- /dev/null
+++ b/inf/zotks/3/prog.c
@@ -0,0 +1,49 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+int main (int argc, char ** argv) {
+ size_t k[200000];
+ char b[2000000];
+ size_t d = 0;
+ char * p = NULL;
+ char ne[128];
+ char * nu = fgets(ne, 127, stdin);
+ nu++; nu--;
+ size_t n = strtoll(ne, NULL, 10);
+ char c = fgetc(stdin);
+ while (!feof(stdin)) {
+ b[d++] = c;
+ c = fgetc(stdin);
+ }
+ if (b[d-1] == '\n') /* ce je input slucajno koncan z EOL */
+ d--;
+ if (b[d-1] == '\r') /* ce se slucajno uporablja slab operacijski sistem */
+ d--;
+ b[d] = '\0';
+ d = 0;
+ p = b;
+ do {
+ k[d] = strtol(p, &p, 10);
+ p++; /* sizeof(char) je itak 1 */
+ d++;
+ } while (p[-1] != '\0');
+ d;
+ size_t korakov = 0;
+ size_t temp = 0;
+ for (long int zz = 0; zz < d; zz++) {
+ /* fprintf(stderr, "%lu %lu %lu %lu %lu\n", k[0], k[1], k[2], k[3], k[4]); */
+ if (k[zz] == zz+1) {
+ korakov++;
+ temp = k[0];
+ memcpy(&(k[0]), &(k[1]), sizeof(size_t)*(d-1));
+ k[d-1] = temp;
+ zz = -1;
+ }
+ if (korakov >= d) {
+ fprintf(stdout, "-1\n");
+ return 0;
+ }
+ }
+ fprintf(stdout, "%lu\n", korakov);
+ return 0;
+}