#1136
Dragoni
Supărați că lansarea părții a treia a filmului lor preferat s-a amânat până în iunie 2018, Henry și Hetty s-au gândit la propriul scenariu pentru finalul trilogiei:
Într-o lume în care vikingii pot zbura cu dragonii există N
insule. Hiccup, șeful tribului de vikingi aflat pe insula 1
, știe M
rute directe de zbor bidirecționale între insule. Pentru fiecare j
intre 1
si M
, ruta j
unește insulele A
j
și B
j
și are lungime D
j
.
Pe fiecare insulă i
, (1 ≤ i ≤ n
) există dragoni din specia i
care pot zbura fără a se opri pentru odihnă o distanță maximă Dmax
i
. Cu alte cuvinte, dragonii de pe insula i
vor putea parcurge orice rută j
, (1 ≤ j ≤ m
) pentru care D
j
≤ Dmax
i
, indiferent de ce alte drumuri au făcut anterior.
Hiccup dorește să ajungă de pe insula 1
pe insula N
pentru a-l salva pe Toothless, dragonul lui. Pentru a ajunge acolo, el va lua inițial un dragon din specia 1
(de pe insula 1
). Apoi, dacă la un moment dat Hiccup se află pe o insula i
, (1 ≤ i ≤ n
) având cu el un dragon din specia t
, el poate:
i
pe o altă insulă x
cu dragonul pe care îl are, folosind o rută directă j
între insulele i
si x
, bineînțeles doar dacă D
j
≤ Dmax
t
.t
pe care îl are cu un dragon din specia i
aflat pe insula respectivă.Cerințe:
a. Să se determine distanța maxima Dmax
i
caracteristică unui dragon la care Hiccup poate ajunge fără a schimba dragonul pe care l-a luat inițial de pe insula 1
.
b. Să se determine distanța minimă pe care Hiccup trebuie să o parcurgă pentru a ajunge de pe insula 1
pe insula N
.
OJI 2015, Clasele XI-XII
Problema | Dragoni | Operații I/O |
dragoni.in /dragoni.out
|
---|---|---|---|
Limita timp | 1.5 secunde | Limita memorie |
Total: 32 MB
/
Stivă 8 MB
|
Id soluție | #15185935 | Utilizator | |
Fișier | dragoni.c | Dimensiune | 1.14 KB |
Data încărcării | 03 Aprilie 2019, 20:57 | Scor / rezultat | Eroare de compilare |
dragoni.c: In function 'setify': dragoni.c:17:26: error: invalid operands to binary && (have 'int' and 'Pereche') if (set[i].dist < dist && set[i] ^ dragoni.c:18:1: error: expected ')' before '}' token } ^ dragoni.c:18:1: error: expected expression before '}' token dragoni.c: In function 'fillper': dragoni.c:30:12: error: 'x' undeclared (first use in this function) setify(x,y); ^ dragoni.c:30:12: note: each undeclared identifier is reported only once for each function it appears in dragoni.c:30:14: error: 'y' undeclared (first use in this function) setify(x,y); ^ dragoni.c:30:5: error: too few arguments to function 'setify' setify(x,y); ^ dragoni.c:11:6: note: declared here void setify(Pereche *set, int setlen, long long dist, int dmin) ^ dragoni.c:33:5: warning: 'main' is normally a non-static function [-Wmain] int main() ^ dragoni.c: In function 'main': dragoni.c:40:2: warning: passing argument 1 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d", &p); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'struct FILE * __restrict__' but argument is of type 'char *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:40:2: warning: passing argument 2 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d", &p); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'const char * __restrict__' but argument is of type 'int *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:40:2: warning: format not a string literal and no format arguments [-Wformat-security] fscanf("%d", &p); ^ dragoni.c:41:2: warning: passing argument 1 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d%d", &N, &M); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'struct FILE * __restrict__' but argument is of type 'char *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:41:2: warning: passing argument 2 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d%d", &N, &M); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'const char * __restrict__' but argument is of type 'int *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:43:3: warning: passing argument 1 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d", dragoni + i); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'struct FILE * __restrict__' but argument is of type 'char *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:43:3: warning: passing argument 2 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d", dragoni + i); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'const char * __restrict__' but argument is of type 'int *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:43:3: warning: format not a string literal and no format arguments [-Wformat-security] fscanf("%d", dragoni + i); ^ dragoni.c:44:16: warning: value computed is not used [-Wunused-value] for (i = 0, i < M; ++i) { ^ dragoni.c:44:24: error: expected ';' before ')' token for (i = 0, i < M; ++i) { ^ dragoni.c:45:3: warning: passing argument 1 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d%d", &a, &b); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'struct FILE * __restrict__' but argument is of type 'char *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:45:3: warning: passing argument 2 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d%d", &a, &b); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'const char * __restrict__' but argument is of type 'int *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:46:3: warning: passing argument 1 of 'fscanf' from incompatible pointer type [enabled by default] fscanf("%d", ad[a][b]); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'struct FILE * __restrict__' but argument is of type 'char *' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:46:3: warning: passing argument 2 of 'fscanf' makes pointer from integer without a cast [enabled by default] fscanf("%d", ad[a][b]); ^ In file included from /usr/include/features.h:374:0, from /usr/include/stdio.h:27, from dragoni.c:1: /usr/include/stdio.h:443:12: note: expected 'const char * __restrict__' but argument is of type 'int' extern int __REDIRECT (fscanf, (FILE *__restrict __stream, ^ dragoni.c:46:3: warning: format not a string literal and no format arguments [-Wformat-security] fscanf("%d", ad[a][b]); ^ dragoni.c:52:3: error: 'l' undeclared (first use in this function) l; ^ dragoni.c:57:4: warning: implicit declaration of function 'malloc' [-Wimplicit-function-declaration] per[i] = malloc(sizeof(Pereche)); ^ dragoni.c:57:13: warning: incompatible implicit declaration of built-in function 'malloc' [enabled by default] per[i] = malloc(sizeof(Pereche)); ^ dragoni.c:57:11: error: incompatible types when assigning to type 'struct Pereche[800]' from type 'void *' per[i] = malloc(sizeof(Pereche)); ^ dragoni.c:54:7: warning: variable 'len' set but not used [-Wunused-but-set-variable] int len[800]; ^ dragoni.c:62:2: error: expected declaration or statement at end of input return 0; ^ dragoni.c: In function 'fillper': dragoni.c:62:2: error: expected declaration or statement at end of input dragoni.c:62:2: error: expected declaration or statement at end of input dragoni.c:22:9: warning: unused variable 'j' [-Wunused-variable] int i, j; ^ dragoni.c: In function 'setify': dragoni.c:62:2: error: expected declaration or statement at end of input return 0; ^ dragoni.c:13:6: warning: unused variable 'necesar' [-Wunused-variable] int necesar, i; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Dragoni face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.