Afişează mesaje
|
Pagini: 1 2 [3] 4 5 ... 26
|
53
|
infoarena - concursuri, probleme, evaluator, articole / .CAMPION / Răspuns: Time limit exceeded
|
: Iunie 04, 2011, 15:18:30
|
Ok, am vazut acum. La campion nu se prea dau punctaje partiale, si cred ca asta e pb. Inca ceva, pe campion este un evaluator mult mai bun ca pe infaorena sau cel de la ONI, si reducand limita de timp (uneori prea mare) apare TLE.
Aici vorbesti prostii. Evaluatorul campion nu e deloc mai bun fata de cel de pe infoarena, foloseste daca nu ma insel gcc 3.4, are o gramada de bug-uri, printre care si ca iti afiseaza kill by signal 11 desi tu iei memory limit exceeded. Iti aloca o anumita memorie si daca iesi din ea iei kbs 11, si nu prea ai cum sa iti dai seama. Un alt bug e ca iti arata exit code-ul, sau chiar scorul uneori , lucru care nu e ok intr-un concurs live. @Petru Dimitriu, tu probabil iei tle pentru ca s-a micsorat limita de timp ca sa nu mai intre bulaneli. Tu pe ce calculator testezi ?
|
|
|
56
|
infoarena - concursuri, probleme, evaluator, articole / Informatica / Răspuns: Graf hamiltonian
|
: Mai 26, 2011, 18:39:07
|
Bondy–Chvátal theorem
The best vertex degree characterization of Hamiltonian graphs was given in 1972 by the Bondy–Chvátal theorem which generalizes earlier results by G. A. Dirac (1952) and Øystein Ore. In fact, both Dirac's and Ore's theorems are less powerful than what can be derived from Pósa's theorem (1962). Dirac and Ore's theorems basically state that a graph is Hamiltonian if it has enough edges. First we have to define the closure of a graph. Given a graph G with n vertices, the closure cl(G) is uniquely constructed from G by successively adding for all nonadjacent pairs of vertices u and v with degree(v) + degree(u) ≥ n[clarification needed] the new edge uv. Bondy–Chvátal theorem A graph is Hamiltonian if and only if its closure is Hamiltonian. As complete graphs are Hamiltonian, all graphs whose closure is complete are Hamiltonian, which is the content of the following earlier theorems by Dirac and Ore. Dirac (1952) A simple graph with n vertices (n ≥ 3) is Hamiltonian if each vertex has degree n/2 or greater.[1] Ore (1960) A graph with n vertices (n ≥ 3) is Hamiltonian if, for each pair of non-adjacent vertices, the sum of their degrees is n or greater (see Ore's theorem). The following theorems can be regarded as directed versions: Ghouila-Houiri (1960) A strongly connected simple directed graph with n vertices is Hamiltonian if some vertex has a full degree smaller than n. Meyniel (1973) A strongly connected simple directed graph with n vertices is Hamiltonian if the sum of full degrees of some two distinct non-adjacent vertices is smaller than 2n − 1. The number of vertices must be doubled because each undirected edge corresponds to two directed arcs and thus the degree of a vertex in the directed graph is twice the degree in the undirected graph.
Mai mult de atat nu cred ca gasesti.
|
|
|
57
|
Comunitate - feedback, proiecte si distractie / Blog / Răspuns: SQL query
|
: Mai 25, 2011, 11:15:53
|
Facem pargurgerea euler a ierarhiei initiale, si introducem in baza de date pe rand in ordinea din parcurgerea euler. Vom tine id-ul minim si maxim al nodurilor din subarbore pt fiecare nod (sunt consecutive nodurile din subarbore). Pt un query se verifica daca t1[y] < t1[ x ] < t2[y].
Ce zice Cosmin Tutunaru e corect dar nu e practic. Nu prea e ok din punct de vedere SQL sa ti multe referinte catre acelasi tabel pe aceeasi obiect sql (linie din tabel). Cel putin asa stiu....
|
|
|
58
|
infoarena - concursuri, probleme, evaluator, articole / Informatica / Răspuns: arbore de cautare
|
: Mai 17, 2011, 18:56:12
|
#include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h>
typedef struct { char nume[15]; char prenume[15]; int media; int grupa; } informatie;
typedef struct nod { informatie inf; struct nod *st,*dr; } t_nod;
nod *a;
nod *CREARE(nod *rad) { if(rad!=NULL) { printf("\n Arborele este creat"); return rad; } else { rad=new nod; printf(" Numele:"); scanf("%s",rad->inf.nume); printf(" Prenumele:"); scanf("%s",rad->inf.prenume); printf(" Media:"); scanf("%d",&rad->inf.media); printf(" Grupa:"); scanf("%d",&rad->inf.grupa); rad->st=NULL; rad->dr=NULL; printf("\n Arborele a fost creat"); return rad; } } nod *INSERARE(nod *rad, char k[15]) { int aux; if(rad==NULL) { rad=new nod; strcpy(rad->inf.nume,k); printf(" Prenumele:"); scanf("%s",rad->inf.prenume); printf(" Media:"); scanf("%d",&rad->inf.media); printf(" Grupa:"); scanf("%d",&rad->inf.grupa); rad->st=NULL; rad->dr=NULL; return rad; } else { aux=strcmp(rad->inf.nume,k); if(aux==0) { printf("\n Numele acesta exista"); getch(); return rad; } if(aux<0) rad->st=INSERARE(rad->st,k); else rad->dr=INSERARE(rad->dr,k); } return rad; }
void LIST(nod *rad) { if(rad) { LIST(rad->dr); { printf("\n Numele:%s\n",rad->inf.nume); printf(" Prenumele:%s\n",rad->inf.prenume); printf(" Media:%d\n",rad->inf.media); printf(" Grupa:%d\n",rad->inf.grupa); } LIST(rad->st); } }
void MODIFICARE(nod *rad, char k[15]) { int aux; aux=strcmp(rad->inf.nume,k); if(aux==0) { printf(" Prenumele:"); scanf("%s",rad->inf.prenume); printf(" Media:"); scanf("%d",&rad->inf.media); printf(" Grupa:"); scanf("%d",&rad->inf.grupa); } else if(aux!=0 && rad->st!=NULL) MODIFICARE(rad->st,k); else if(aux!=0 && rad->dr!=NULL) MODIFICARE(rad->dr,k); }
nod *DEL(nod *p, nod *q, nod *r) { if(p->dr!=NULL) DEL(p->dr,q,r); else { p->dr=r; q=q->st; } return(0); }
void DELETE(nod *rad, char k[15]) { int aux; nod *q; aux=strcmp(k,rad->inf.nume); if(aux<0) DELETE(rad->st,k); else if(aux>0) DELETE(rad->dr,k); else { q=rad; if(q->dr==NULL) rad=q->st; else if(q->st==NULL) rad=q->dr; else DEL(q->st,q,q->dr); } delete rad; }
void main() { char ch,litera,k[15]; do { clrscr(); printf("\n 1. Crearea arborelui \n 2. Inserare \n 3. Listare"); printf("\n 4. Modificare \n 5. Stergere \n 0. Exit \n "); ch=getch(); switch(ch) { case '1': clrscr(); a=CREARE(a); getch(); break; case '2': clrscr(); if(a==NULL) printf("\n Trebuie sa creati arborele"); else { do { clrscr(); printf("\n Numele:"); scanf("%s",k); INSERARE(a,k); printf("\n Continuati?"); litera=getch(); } while((litera!='n')&&(litera!='N')); } getch(); break; case '3': clrscr(); if(a==NULL) printf("\n Trebuie sa creati arborele"); else { clrscr(); LIST(a); } getch(); break; case '4': clrscr(); if(a==NULL) printf("\n Trebuie sa creati arborele"); else { printf("\n Numele:"); scanf("%s",k); MODIFICARE(a,k); } getch(); break; case '5': clrscr(); if(a==NULL) printf("\n Trebuie sa creati arborele"); else { printf("\n Numele:"); scanf("%s",k); DELETE(a,k); printf("\n Nodul a fost sters"); } getch(); break; } } while(ch!='0'); }
Acesta e codul la stergere: nod *DEL(nod *p, nod *q, nod *r) { if(p->dr!=NULL) DEL(p->dr,q,r); else { p->dr=r; q=q->st; } return(0); }
void DELETE(nod *rad, char k[15]) { int aux; nod *q; aux=strcmp(k,rad->inf.nume); if(aux<0) DELETE(rad->st,k); else if(aux>0) DELETE(rad->dr,k); else { q=rad; if(q->dr==NULL) rad=q->st; else if(q->st==NULL) rad=q->dr; else DEL(q->st,q,q->dr); } delete rad; }
Posteaza si tu formatat frumos, altfel nu cred ca o sa te ajute nimeni .
|
|
|
|