#1493
Masca
Se consideră alfabetul compus din literele mici, de la a
la z
, fără diacritice. Se numeşte cuvânt un şir finit, eventual vid, de litere din alfabet. Se numeşte mască un şir de caractere din alfabet având eventual în plus caracterele ?
şi *
cu următoarea semnificaţie: caracterul ?
înlocuieşte oricare din literele de la a
la z
(o singură literă) iar caracterul *
înlocuieşte un cuvânt oarecare, eventual vid, format cu litere de la a
la z
.
Spre exemplu avem masca a?b*c
. Dacă avem 3
cuvinte şi anume abbc
, acbaac
şi abac
atunci primele 2
se potrivesc cu masca.
Considerându-se o listă de cuvinte, să se determine:
a) Numărul de cuvinte distincte.
b) Numărul de cuvinte distincte ce se potrivesc cu o mască dată, adică se pot obţine prin înlocuirea caracterelor ?
şi *
din mască.
Olimpiada locală de Informatică, Prahova, 2016
Problema | Masca | Operații I/O |
masca.in /masca.out
|
---|---|---|---|
Limita timp | 0.5 secunde | Limita memorie |
Total: 4 MB
/
Stivă 2 MB
|
Id soluție | #49107965 | Utilizator | |
Fișier | masca.cpp | Dimensiune | 1.73 KB |
Data încărcării | 15 Februarie 2024, 13:26 | Scor / rezultat | Eroare de compilare |
masca.cpp:7:9: error: too many decimal points in number x:array[1..1000]of string; ^ masca.cpp:12:8: error: empty character constant if exp='' then if s='' then f:=true ^ masca.cpp:12:21: error: empty character constant if exp='' then if s='' then f:=true ^ masca.cpp:16:9: error: empty character constant if s<>'' then ^ masca.cpp:24:20: error: empty character constant else {s=''} f:=false ^ masca.cpp:27:10: error: empty character constant if s<>'' then ^ masca.cpp:48:15: warning: character constant too long for its type [enabled by default] assign(fisier,'masca.in'); ^ masca.cpp:93:15: warning: multi-character character constant [-Wmultichar] writeln(x[j],' DA'); ^ masca.cpp:95:9: warning: multi-character character constant [-Wmultichar] writeln('nr=',k);} ^ masca.cpp:97:10: warning: character constant too long for its type [enabled by default] assign(g,'masca.out'); ^ masca.cpp:1:1: error: 'program' does not name a type program sablon; ^ masca.cpp:2:1: error: 'var' does not name a type var fisier,g:text; ^ masca.cpp:3:1: error: 'exp' does not name a type exp,s:string; ^ masca.cpp:4:1: error: 'n' does not name a type n,i,j,k:integer; ^ masca.cpp:5:2: error: found ':' in nested-name-specifier, expected '::' p:integer; ^ masca.cpp:5:1: error: 'p' does not name a type p:integer; ^ masca.cpp:6:6: error: found ':' in nested-name-specifier, expected '::' gasit:boolean; ^ masca.cpp:6:1: error: 'gasit' does not name a type gasit:boolean; ^ masca.cpp:7:2: error: found ':' in nested-name-specifier, expected '::' x:array[1..1000]of string; ^ masca.cpp:7:1: error: 'x' does not name a type x:array[1..1000]of string; ^ masca.cpp:9:1: error: 'function' does not name a type function f(exp,s:string):boolean; ^ masca.cpp:10:1: error: 'var' does not name a type var i:integer;ok:boolean; ^ masca.cpp:10:17: error: found ':' in nested-name-specifier, expected '::' var i:integer;ok:boolean; ^ masca.cpp:10:15: error: 'ok' does not name a type var i:integer;ok:boolean; ^ masca.cpp:11:1: error: 'begin' does not name a type begin ^ masca.cpp:20:21: error: expected unqualified-id before 'delete' delete(s,1,1); ^ masca.cpp:21:21: error: 'f' does not name a type f:=f(exp,s) ^ masca.cpp:23:39: error: 'f' does not name a type else {s[1]<>exp[1]} f:=false ^ masca.cpp:24:24: error: 'f' does not name a type else {s=''} f:=false ^ masca.cpp:30:15: error: expected unqualified-id before 'delete' delete(s,1,1); ^ masca.cpp:31:15: error: 'f' does not name a type f:=f(exp,s) ^ masca.cpp:35:4: error: 'begin' does not name a type begin ^ masca.cpp:37:4: error: 'ok' does not name a type ok:=f(exp,s); ^ masca.cpp:38:4: error: expected unqualified-id before 'for' for i:=1 to length(s) do ^ masca.cpp:41:5: error: 'ok' does not name a type ok:=ok or f(exp,s); ^ masca.cpp:42:5: error: 'end' does not name a type end; ^ masca.cpp:43:4: error: 'f' does not name a type f:=ok; ^ masca.cpp:44:4: error: 'end' does not name a type end; ^ masca.cpp:45:1: error: 'end' does not name a type end; ^ masca.cpp:47:1: error: 'begin' does not name a type begin ^ masca.cpp:49:6: error: expected constructor, destructor, or type conversion before '(' token reset(fisier); ^ masca.cpp:50:7: error: expected constructor, destructor, or type conversion before '(' token readln(fisier,p); ^ masca.cpp:51:7: error: expected constructor, destructor, or type conversion before '(' token readln(fisier,exp); ^ masca.cpp:52:7: error: expected constructor, destructor, or type conversion before '(' token readln(fisier,n); ^ masca.cpp:53:1: error: expected unqualified-id before 'if' if p=2 then ^ masca.cpp:56:1: error: expected unqualified-id before 'for' for i:=1 to n do ^ masca.cpp:59:2: error: expected unqualified-id before 'if' if f(exp,s) then ^ masca.cpp:62:3: error: expected unqualified-id before 'for' for j:=1 to k do ^ masca.cpp:64:3: error: expected unqualified-id before 'if' if not(gasit) then ^ masca.cpp:66:4: error: 'x' does not name a type x[k]:=s; ^ masca.cpp:67:4: error: 'end' does not name a type end; ^ masca.cpp:68:3: error: 'end' does not name a type end; ^ masca.cpp:69:2: error: 'end' does not name a type end; ^ masca.cpp:70:6: error: expected constructor, destructor, or type conversion before '(' token close(fisier); ^ masca.cpp:71:1: error: 'end' does not name a type end ^ masca.cpp:75:1: error: expected unqualified-id before 'for' for i:=1 to n do ^ masca.cpp:78:3: error: 'begin' does not name a type begin ^ masca.cpp:80:3: error: expected unqualified-id before 'for' for j:=1 to k do ^ masca.cpp:82:3: error: expected unqualified-id before 'if' if not(gasit) then ^ masca.cpp:84:4: error: 'x' does not name a type x[k]:=s; ^ masca.cpp:85:4: error: 'end' does not name a type end; ^ masca.cpp:86:3: error: 'end' does not name a type end; ^ masca.cpp:87:2: error: 'end' does not name a type end; ^ masca.cpp:88:6: error: expected constructor, destructor, or type conversion before '(' token close(fisier); ^ masca.cpp:89:1: error: 'end' does not name a type end; ^ masca.cpp:91:1: error: expected unqualified-id before '{' token {writeln(exp); ^ masca.cpp:97:7: error: expected constructor, destructor, or type conversion before '(' token assign(g,'masca.out'); ^ masca.cpp:98:8: error: expected constructor, destructor, or type conversion before '(' token rewrite(g); ^ masca.cpp:99:8: error: expected constructor, destructor, or type conversion before '(' token writeln(g,k); ^ masca.cpp:100:6: error: expected constructor, destructor, or type conversion before '(' token close(g); ^ masca.cpp:101:1: error: 'end' does not name a type end. ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Masca 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ă.