Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
Страница 3 |
BBBBBBBBUG!!! | vagrant | 1022. Генеалогическое дерево | 22 окт 2010 22:10 | 1 |
#include<iostream> using namespace std; void main() { int n,i=0,t,a[102]={-1}; cin>>n; int num[1020]={-1}; for(int j=1;j<=n;j++) { do { i++; cin>>num[i]; }while(num[i]!=0); t=num[1]; num[1]=0; for(int m=2;m<i;m++) { if(t<num[m]) t=num[m]; num[m]=0; } a[j]=t; } for(int j=1;j<=n;j++) { t=j; for(int m=1;m<=n;m++) { if(a[t]<a[m]) t=m; } cout<<t<<" "; a[t]=-1; } } AAAAACCEPTED!!!!! WHY? |
It is very easy just make topogical sort!!!!!!! | Tigran92[RAU] | 1022. Генеалогическое дерево | 19 окт 2010 18:57 | 1 |
|
there is bug in checker | Tapyshpan Denis | 1022. Генеалогическое дерево | 10 окт 2010 19:46 | 1 |
esli vyvodit' otvet otdel'no dlya kajdoj komponenty svyaznosti, to poluchaesh WA. esli sobrat' vse otvety(dlya vseh komponent svyaznosti) i srazu vyvesti, to poluchaesh AC. raznica lish' v poryadke vyvoda otvetov. |
WA#2 | HaaS | 1022. Генеалогическое дерево | 22 янв 2011 16:24 | 3 |
WA#2 HaaS 5 окт 2010 20:26 I was WA#2 and now I get Ac, because: Graph can be not connected Re: WA#2 Nguyen Khac Tung 24 окт 2010 13:05 I got WA#2 too, but I thought that the graph is supposed to be not connected. Can help me identify my errors , here's my solution : - I reverse all the edges - DFS from the vertex without any other vertex pointing to - Count the depth, if depth = number of vertex -> output in reverse order 3Q,i made the same mistake,and i now get AC |
No subject | Andrew Hoffmann aka SKYDOS [Vladimir SU] | 1022. Генеалогическое дерево | 20 ноя 2011 02:51 | 4 |
No subject Andrew Hoffmann aka SKYDOS [Vladimir SU] 26 июл 2010 14:36 Edited by author 26.07.2010 15:12 One of the lines in test 4 has trailing space. This old problem was designed for Pascal/C++, such inputs treated as a bad style nowadays. Re: To Admins Andrew Hoffmann aka SKYDOS [Vladimir SU] 26 июл 2010 15:22 Thanks for info. I have changed something in my program now not to "look" on any unnecessary spaces. Thanks for the info. You've saved my time :) |
what is the floyde-warshall | Xan Tei Jun | 1022. Генеалогическое дерево | 28 окт 2009 11:59 | 3 |
It is an algorithm with complexity O(N^3) to find shortest distance between all vertices of a graph. Thaks a lot. I didn't notice this is an algorithm of Floid |
What is topological sorting in graph | Xan Tei Jun | 1022. Генеалогическое дерево | 28 окт 2009 11:53 | 3 |
Could anybody explain me what is the topological sorting. I don't understand well graphs. so what is this algorithm and how it can be realized? Send me e-mail please: shohruhhon1@mail.ru thanx in advance |
What answer will be for a example : | Chabanenko Vlad | 1022. Генеалогическое дерево | 19 июл 2009 19:17 | 2 |
3 2 0 3 0 1 0 Your example isn't correct. "At least one such sequence always exists." |
WA#1 | Sergey Zuev (LYC) | 1022. Генеалогическое дерево | 29 мар 2010 08:40 | 4 |
WA#1 Sergey Zuev (LYC) 24 апр 2009 18:01 I think my solution is right, I tried it on many test, but the system gives WA#1. Could you give me this test? System gives WA#1 me too. ____ Sorry for my English. Edited by author 29.01.2010 23:40 Re: WA#1 Dyudin Grigoriy 28 мар 2010 16:54 WA#2 :( but I think my solution is right i'm think yoursolution not right or not enough case. See you later. good look |
Weak tests | Fyodor Menshikov | 1022. Генеалогическое дерево | 18 мар 2009 00:20 | 1 |
I know AC solution that answers 3 2 1 for test 3 0 3 0 1 0 The only right answer for this test is 2 3 1 |
what is the 6 test | lisang | 1022. Генеалогическое дерево | 2 фев 2009 22:27 | 1 |
plese who can give me a 6 test! |
WHY? | akmal4ik | 1022. Генеалогическое дерево | 2 авг 2011 13:31 | 3 |
WHY? akmal4ik 11 дек 2008 23:04 5 0 4 5 1 0 1 0 5 3 0 3 0 Why output is: 2 4 5 3 1 not: 2 4 3 5 1 and i can't understand the WA in test#4 please explain me chunki 3 5ni farzandi Edited by author 08.07.2011 16:39 |
Compilation error in Pascal | TUIT_MAD | 1022. Генеалогическое дерево | 4 мар 2008 18:31 | 2 |
program mars; uses crt; var a,b:array[1..100] of integer; i,j,k,n,max,min,s,p:integer; begin clrscr; {Vvod} readln(n); s:=0; for i:=1 to n do begin for j:=1 to n-1 do begin {write('a[',j,']=');} read(a[j]); if a[j]=0 then begin for k:=j to n-1 do a[k]:=0; j:=k; end; s:=s+a[j]; end; b[i]:=s; s:=0; end; {Sortirovka i vivod} min:=b[1]; for i:=1 to n do if b[i]<=min then begin min:=b[i]; p:=i; end; for j:=1 to n do begin max:=b[1]; for i:=1 to n do begin if b[i]>max then begin max:=b[i]; a[j]:=i; k:=i; end; end; b[k]:=0; end; a[n]:=p; for i:=1 to n do write(a[i],' '); readkey; end. You tried to solve problem 1022 Genealogical tree. Your solution was compiled with the following errors: 8421e763-05ba-4aea-b470-f7f9a3d55a5e(16,5) Error: Illegal assignment to for-loop variable "j" 8421e763-05ba-4aea-b470-f7f9a3d55a5e(39,4) Fatal: There were 1 errors compiling module, stopping 8421e763-05ba-4aea-b470-f7f9a3d55a5e(39,4) Fatal: Compilation aborted You cannot modify iterator in for-loop directly, replace for j:=1 to 2 do begin if 1=2 then j := 3; end; with j := 1; while j <= 2 do begin if 1=2 then j := 3; inc(j); end; And don't use unit crt, read FAQ about how to do input/output. |
HELP!! HELP!! | byron1990 | 1022. Генеалогическое дерево | 29 ноя 2007 10:16 | 1 |
Why this program is wrong? Who can help me? var i,j,k,m,n,l :longint; d :array[1..1000]of longint; boo :array[1..100,1..100]of boolean; begin fillchar(boo,sizeof(boo),false); readln(n); for i:=1 to n do begin while not eoln do begin read(k); if k<>0 then begin boo[i,k]:=true; inc(d[k]); end; end; readln; end; for i:=1 to n do begin j:=1; while (d[j]<>0)and(j<=n) do inc(j); write(j,' '); d[j]:=maxlongint; for l:=1 to n do if boo[j,l]=true then begin dec(d[l]); boo[j,l]:=false ; end; end; end. |
floyde-warshall works on this problem | Snetch | 1022. Генеалогическое дерево | 26 дек 2010 10:07 | 4 |
1888582 05:04:16 29 ноя 2007 Snetch 1022 Pascal Accepted 0.015 179 КБ 2170208 13:57:22 23 июл 2008 Mansurov Artur 1022 C++ Accepted 0.001 153 КБ O(n^2) simple search Can you send me your O(n^2) solution?I got AC with O(n^3) my mail is:keivan.alizadeh@gmail.com |
Compilation Error(Java) | Amaranth | 1022. Генеалогическое дерево | 15 ноя 2007 20:40 | 1 |
So I wrote a programm and in my sollution on Java I have used such method like: ll.removeFirstOccurrence(Integer.valueOf(point)); Where ll is LinkedList But I have got Compilation Error! When I change this line to: ll.remove(Integer.valueOf(point)); I got AC. Can you explain me what is it. |
What's wrong? WA! | suvorov007 | 1022. Генеалогическое дерево | 15 ноя 2007 13:52 | 2 |
There is my sourse below. Topologic sort. It seems to be very simple, and it is, but may be, i don't understand something. Find error, please. Sorry for my english;) program Mars; uses SysUtils; type TPNext = ^ElemIO; ElemIO = record Vert: byte; Next: TPNext; end; var Numbers, Parents: array [1..100] of byte; Point: array [1..100, 0..100] of byte; Beg, En: TPNext; Num, N, w, a, q: Byte; NewV: array [1..100] of boolean; f: Text; procedure Push(v: byte); var ne: TPNext; begin New(ne); if Beg = nil then Beg:= Ne; Ne^.Vert:= V; Ne^.Next:= nil; if En = nil then En:= ne else begin En^.Next:= Ne; En:= Ne; end; end; function Pop: byte; var ne:TPNext; begin result:= Beg^.Vert; Ne:= Beg; Beg:= Ne^.Next; if Beg = nil then En:= nil; Dispose(Ne); end; Procedure OW(v: byte); var i, p: byte; begin Push(v); while Beg <> nil do begin p:= Pop; Numbers[Num]:= p; inc(num); for I := 1 to Point[p, 0] do if NewV[Point[p, i]] then begin Push(Point[p, i]); NewV[Point[p, i]]:= false; end; end; end; procedure GetTheOldest; var i, q: byte; begin FillChar(Parents, N, 0); for i := 1 to N do for q := 1 to Point[i, 0] do inc(Parents[Point[i, q]]); Num:=1; for I := 1 to N do if Parents[i] = 0 then begin OW(i); NewV[i]:= false; end; end; begin for w := 1 to 100 do for a := 0 to 100 do Point[w, a]:= 0; AssignFile(f, 'input.txt'); reset(f); N:=0; read(f, N); for w := 1 to N do begin read(f, a); q:= 1; while a <> 0 do begin Point[w, q]:= a; inc(Point[w, 0]); Read(f, a); inc(q); end; end; CloseFile(f); FillChar(NewV, N, True); Beg:= nil; En:= nil; GetTheOldest; For w:=1 to N do If NewV[w] then OW(w); AssignFile(f, 'output.txt'); rewrite(f); if n <> 0 then for w := 1 to N do if w = N then write(f, Numbers[w]) else write(f, Numbers[w], ' '); CloseFile(f); end. |
drive me mad!!why Compilation error !!?? | bottles | 1022. Генеалогическое дерево | 13 ноя 2007 20:42 | 3 |
#include<iostream> #include<cstdlib> #include<cstdio> using namespace std; struct list{ int num[100]; }; struct graph{ int used; int degree; int parent; struct list* p; }; void initialize(struct graph* g,short int n){ for(int i=1;i<n+1;i++){ g[i].used=0; g[i].degree=0; g[i].parent=0; struct list* p=new list; int number; g[i].p=p; do{ scanf("%d",&number); if(number!=0){ g[i].p->num[g[i].degree++]=number; } }while(number!=0); } } int findzero(struct graph* g,int n) { for(int i=1;i<n+1;i++) if(g[i].parent==0&&(!g[i].used)){ g[i].used=1; return i; } } void topsort(struct graph* g,int n) { for(int i=1;i<n+1;i++){ int v=findzero(g,n);
printf("%d ",v); for(int j=0;j<g[v].degree;j++){ g[g[v].p->num[j]].parent--; } } printf("\n"); } void calparent(struct graph* g,int n) { for(int i=1;i<n+1;i++) for(int j=0;j<g[i].degree;j++) g[g[i].p->num[j]].parent++; } int main() { int n; scanf("%d",&n); struct graph g[n+1]; initialize(g,n); calparent(g,n); topsort(g,n); return 0; } ---------------------------- i got right in my own ide, but in ural it said compilation error!!__why????? when you submit code you can set option "Reply" in "To this E-Mail address"
|
No subject | zura | 1022. Генеалогическое дерево | 3 июн 2007 15:07 | 1 |
How I can write this program? plz tell me |
program | saba | 1022. Генеалогическое дерево | 14 авг 2007 09:55 | 2 |
I want c++ program which gives AC Edited by author 02.06.2007 20:02 #include <iostream> #include <vector> #include <set> using namespace std; int main() { int i, k, n; cin >> n; vector< set<int> > out(n), in(n); for (i=0;i<n;i++) while (cin>>k, k) { out[i].insert(--k); in[k].insert(i); } set<int> q; for (i=0;i<n;i++) if (in[i].empty()) q.insert(i); vector<int> top; while (!q.empty()) { top.push_back(k=*q.begin()); q.erase(q.begin()); for (set<int>::iterator it=out[k].begin();it!=out[k].end();++it) { i=*it; in[i].erase(k); if (in[i].empty()) q.insert(i); } } cout << top[0]+1; for (i=1;i<n;i++) cout << ' ' << top[i]+1; return 0; } |