Общий форумvar i: longint; begin randomize; for i:=1 to 1000000 do write(chr(ord('a')+random(26))); end. #include<stdio.h> #include<string.h> #define max 251 int n,total,note[max][max],result[max]; void init() { int i,j,t; memset(note,0,sizeof(note)); scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&t); while(t!=-1) { note[t][i]=1;note[t][0]=1; scanf("%d",&t); } } } int judge() { int i; for(i=1;i<=n;i++) if(!note[i][0])return 1; return 0; } void change(int a,int b) { int i,temp[max]; for(i=1;i<=n;i++)temp[i]=note[a][i]; for(i=1;i<=n;i++)note[a][i]=note[b][i]; for(i=1;i<=n;i++)note[b][i]=temp[i]; } void find(int a,int s) { int i,j; for(i=s+1;i<=n;i++) if(note[i][a]) { note[i][0]=(note[i][0]+note[s][0])%2; for(j=1;j<=n;j++) note[i][j]=(note[i][j]+note[s][j])%2; } } void work() { int i,j,sum; if(judge()){total=1;return;}else total=0; for(i=1;i<=n;i++) { for(j=i;j<=n;j++)if(note[j][i])break; change(i,j); find(i,j); } for(i=n;i>0;i--) { if(!note[i][i]){total=1;return;} sum=note[i][0]; for(j=i+1;j<=n;j++)if(note[i][j])sum+=result[j]; result[i]=sum%2; } } void out() { int i,j; if(total)printf("No solution\n"); else { for(i=1;i<=n;i++) if(result[i])break; if(result[i])printf("%d",i); for(j=i+1;j<=n;j++) if(result[j]) printf(" %d",j); printf("\n"); } } int main() { init(); work(); out(); return 0; } #include<stdio.h> #include<string.h> #define max 300 int n,total,note[max][max],result[max]; void init() { int i,j,t; memset(note,0,sizeof(note)); scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d",&t); while(t!=-1) { note[t][i]=(note[t][i]+1)%2;note[t][0]=1; scanf("%d",&t); } } } int judge() { int i; for(i=1;i<=n;i++) if(!note[i][0])return 1; return 0; } void change(int a,int b) { int i,temp; for(i=1;i<=n;i++) { temp=note[a][i]; note[a][i]=note[b][i]; note[b][i]=temp; } } void find(int s) { int i,j; for(i=s+1;i<=n;i++) if(note[i][s]) { for(j=0;j<=n;j++) note[i][j]=(note[i][j]+note[s][j])%2; } } void work() { int i,j,sum; if(judge()){total=1;return;}else total=0; for(i=1;i<=n;i++) { for(j=i;j<=n;j++)if(note[j][i])break; change(i,j); find(i); } for(i=n;i>0;i--) { if(!note[i][i]){total=1;return;} sum=note[i][0]; for(j=i+1;j<=n;j++)if(note[i][j])sum+=result[j]; result[i]=sum%2; } } void out() { int i,j; if(total)printf("No solution\n"); else { for(i=1;i<=n;i++) if(result[i])break; if(result[i])printf("%d",i); for(j=i+1;j<=n;j++) if(result[j]) printf(" %d",j); printf("\n"); } } int main() { init(); work(); out(); return 0; } [code deleted] Edited by moderator 09.12.2019 18:47 [code deleted] Edited by moderator 09.12.2019 18:47 write your MAN follow this, thanks! > write your MAN follow this, thanks! My solution here: const max=160; var g:array[1..max,1..max] of integer; x,y:array[1..max] of boolean; link,lx,ly:array[1..max] of longint; n,num:longint; procedure readdata; var i,j:integer; begin readln(n); for i:=1 to n do begin for j:=1 to n-1 do read(g[i,j]); readln(g[i,n]); end; end; function find(i:integer):boolean; var k,p:integer; begin find:=true; x[i]:=true; for k:=1 to n do if not y[k] and (lx[i]+ly[k]=g[i,k]) then begin p:=link[k];link[k]:=i;y[k]:=true; if (p=0) or find(p) then exit; link[k]:=p; end; find:=false; end; procedure main; var i,j,d:integer; begin for i:=1 to n do for j:=1 to n do if g[i,j]>lx[i] then lx[i]:=g[i,j]; for i:=1 to n do repeat fillchar(x,sizeof(x),0);fillchar(y,sizeof(y),0); if find(i) then break; for i:=1 to n do if x[i] then for j:=1 to n do if not y[j] then if lx[i]+ly[j]-g[i,j]<d then d:=lx[i]+ly[j]-g[i,j]; for i:=1 to n do if x[i] then lx[i]:=lx[i]-d; for j:=1 to n do if y[j] then ly[j]:=ly[j]+d; until false; end; function did(a,b:integer):boolean; var k:integer; m:longint; begin k:=a;did:=false;m:=a; while k>1 do begin dec(k);m:=m*k; if m>b then exit; end; if m=b then did:=true; end; procedure print; var i,j:integer; begin for i:=1 to n do for j:=1 to n do if link[j]=i then else begin if (i>=link[j])or(i>=6) then num:=num+g[i,j] else if did(i,link[j]) then else num:=num+g[i,j]; end; writeln(num); end; BEGIN readdata; main; print; END. just using top-sort program ex; const maxn=100; var b:array[1..maxn] of integer; g:array[1..maxn,1..maxn] of integer; i,j,k,n:integer;
begin fillchar(b,sizeof(b),0); fillchar(g,sizeof(g),0); readln(n); for i:=1 to n do begin read(j); while (j<>0) do begin inc(b[j]); g[j,i]:=1; read(j); end; end;
for i:=1 to n do begin j:=1; while (b[j]<>0) do inc(j); write(j,' '); b[j]:=maxint; for k:=1 to n do if (g[k,j]=1) then dec(b[k]); end; writeln; end. here is my program,please check it. program ex; const maxn=32767; var f:array[-32768..32767] of boolean; n1,n2,i,x,y:longint; flag:boolean; begin readln(n1); fillchar(f,sizeof(f),0); for i:=1 to n1 do begin readln(x); f[x]:=true; end; readln(n2); flag:=false; for i:=1 to n2 do begin readln(x); y:=10000-x; if (y>=-32768) and (y<=32767) then if f[y] then begin flag:=true; break; end; end; if flag then writeln('YES') else writeln('NO'); end. type n=record ile:integer; a:array[1..1000]of byte end; var num:n; ile,liczba,i:integer; procedure mnoz(bufor:byte); var w,p,j:integer; begin p := 0; for j:=1 to num.ile do begin w := num.a[j] * bufor + p; num.a[j] := w mod 10; p := w div 10; end; if (p > 0) then begin Inc(j); num.a[j] := p; num.ile := num.ile + 1 end end; begin read(liczba); if liczba>=0 then begin if (liczba>=0)and(liczba<=4)then begin if liczba=4 then writeln('3') else if liczba>=0 then writeln('1') else writeln(liczba); halt end; if (liczba-4)mod 3=0 then begin num.a[1]:=4; num.ile:=1; for i:=1 to (liczba-4)div 3 do mnoz(3) end else if liczba mod 3=0 then begin num.a[1]:=3; num.ile:=1; for i:=1 to (liczba div 3)-1 do mnoz(3) end else if liczba mod 3=1 then begin num.a[1]:=2; num.ile:=1; for i:=1 to (liczba)div 3 do mnoz(3) end else begin num.a[1]:=3; num.ile:=1; for i:=1 to (liczba div 3)-1 do mnoz(3) end; for i:=1 to num.ile do write(num.a[num.ile-i+1]) end end. /// this my all program on C++ language #include <stdio.h> int N,LRes; long int Res[200]; void Umn3(void) { int i; long int T,P=0; for (i=0;i<LRes;i++) { T=Res[i]; Res[i]=(P+Res[i]*3)%10000; P=(P+T*3)/10000; } if (P>0) { LRes++; Res[i]=P; } } int main(void) { int i; // freopen("input.txt","rt",stdin); // freopen("output.txt","wt",stdout); scanf("%d",&N); if (N==1) { printf("1"); return 0; } LRes=1; /////////there is the main idea of program - ask me if you'll not /////////understand switch (N%3) { case 0: Res[0]=1; N=N/3; break; case 1: Res[0]=4; N=(N-4)/3; break; case 2: Res[0]=2; N=(N-2)/3; break; } for (i=0;i<N;i++) Umn3(); ////////// printf("%ld",Res[LRes-1]); for (i=LRes-2;i>=0;i--) { if (Res[i]/1000==0) printf("0"); if (Res[i]/100==0) printf("0"); if (Res[i]/10==0) printf("0"); printf("%ld",Res[i]); } return 0; } 1322070819480806636890455259752144365965422032752148167664920368226828 5973467048995407783138506080619639097776968725823559509545821006189118 6534272525795367402762022519832080387801477422896484127439040011758861 8041128947815623094438061566173054086674490506178125480344405547054397 0388958174653682549161362208302685637785822902284163983078878969185564 0408489893760937324217184635993869551676501894058810906042608967143886 4102814350385648747165832010614366132173102768902855220001 > type > n=record > ile:integer; > a:array[1..1000]of byte > end; > > var > num:n; > ile,liczba,i:integer; > > procedure mnoz(bufor:byte); > var > w,p,j:integer; > begin > p := 0; > for j:=1 to num.ile do > begin > w := num.a[j] * bufor + p; > num.a[j] := w mod 10; > p := w div 10; > end; > if (p > 0) then > begin > Inc(j); > num.a[j] := p; > num.ile := num.ile + 1 > end > end; > > begin > read(liczba); > if liczba>=0 then > begin > if (liczba>=0)and(liczba<=4)then > begin > if liczba=4 then writeln('3') > else if liczba>=0 then writeln('1') > else writeln(liczba); > halt > end; > > if (liczba-4)mod 3=0 then (*) > begin > num.a[1]:=4; > num.ile:=1; > for i:=1 to (liczba-4)div 3 do mnoz(3) > end > else if liczba mod 3=0 then > begin > num.a[1]:=3; > num.ile:=1; > for i:=1 to (liczba div 3)-1 do mnoz(3) > end > else if liczba mod 3=1 then <- may be wrong, this condition you already wrote upper (*) (liczba>=4) > begin > num.a[1]:=2; > num.ile:=1; > for i:=1 to (liczba)div 3 do mnoz(3) > end > else > begin > num.a[1]:=3; > num.ile:=1; > for i:=1 to (liczba div 3)-1 do mnoz(3) > end; > > for i:=1 to num.ile do > write(num.a[num.ile-i+1]) > end > end. How can I know that's the end of input? Thank you in advance. > How can I know that's the end of input? > Thank you in advance. Simple you add {$I-} at the beginning of the code and you use eof(input) something like while not eof(f) do read(time); if not eof(f) then......... 1. Are there any rules for output for this program (an '\n' at the end or smth like this)? 2. Can I use includes (ctype.h)? Thank you No contest will be held in this season. Next online contest on acm.timus.ru will follow in October. how many test case? or just process until eof? or ? but how to know EOF in c when using standard input/output? VAR X0, X1, X2 : Extended; Y0, Y1, Y2 : Extended; A, B, C : Extended; A0, B0, C0 : Extended; A1, B1, C1 : Extended; CX, CY, R : Extended; MinX, MaxX, MinY, MaxY : Extended; FUNCTION MyRoundA(A : Extended) : Extended; BEGIN IF Trunc(A) = A THEN MyRoundA := A ELSE MyRoundA := Trunc(A)+1 END; FUNCTION MyRoundB(A : Extended) : Extended; BEGIN IF Trunc(A) = A THEN MyRoundB := A ELSE MyRoundB := Trunc(A)-1 END; BEGIN ReadLn(X0, Y0); ReadLn(X1, Y1); ReadLn(X2, Y2); MinX := X0; IF MinX > X1 THEN MinX := X1; MaxX := X0; IF MaxX < X1 THEN MaxX := X1; MinY := Y0; IF MinY > Y1 THEN MinY := Y1; MaxY := Y0; IF MaxY < Y1 THEN MaxY := Y1; CX := (X0+X1)/2; CY := (Y0+Y1)/2; A := (Y1-Y0); B := (X0-X1); C := X1*Y0-X0*Y1; IF (A <> 0) THEN BEGIN A0 := B/A; B0 := -1; C0 := CY-A0*CX; END ELSE BEGIN A0 := 1; B0 := 0; C0 := -CX; END; CX := (X0+X2)/2; CY := (Y0+Y2)/2; A := (Y2-Y0); B := (X0-X2); C := X2*Y0-X0*Y2; IF (A <> 0) THEN BEGIN A1 := B/A; B1 := -1; C1 := CY-A1*CX; END ELSE BEGIN A1 := 1; B1 := 0; C1 := -CX; END; {center} CX := (B0*C1-B1*C0)/(A0*B1-A1*B0); CY := (A1*C0-A0*C1)/(A0*B1-A1*B0); {radius} R := Sqrt(Sqr(X0-CX)+Sqr(Y0-CY)); {Line (X0,Y0) to (X1,Y1)} A := (Y1-Y0); B := (X0-X1); C := X1*Y0-X0*Y1; IF (A*X2+B*Y2+C)*(A*(CX-R)+B*CY+C) >= 0 THEN MinX := CX-R; IF (A*X2+B*Y2+C)*(A*(CX+R)+B*CY+C) >= 0 THEN MaxX := CX+R; IF (A*X2+B*Y2+C)*(A*CX+B*(CY-R)+C) >= 0 THEN MinY := CY-R; IF (A*X2+B*Y2+C)*(A*CX+B*(CY+R)+C) >= 0 THEN MaxY := CY+R; MinX := MyRoundB(MinX); MaxX := MyRoundA(MaxX); MinY := MyRoundB(MinY); MaxY := MyRoundA(MaxY); IF MinX < -1000 THEN MinX := -1000; IF MinY < -1000 THEN MinY := -1000; IF MaxX > 1000 THEN MaxX := 1000; IF MaxY > 1000 THEN MaxY := 1000; Write((MaxX-MinX)*(MaxY-MinY):0:0); END. {$N+} {$E-} VAR X0, X1, X2 : Extended; Y0, Y1, Y2 : Extended; A, B, C : Extended; A0, B0, C0 : Extended; A1, B1, C1 : Extended; CX, CY, R : Extended; MinX, MaxX, MinY, MaxY : Extended; FUNCTION MyRoundUp(A : Extended) : Extended; BEGIN IF Trunc(A) = A THEN MyRoundUp := Trunc(A) ELSE IF A > 0 THEN MyRoundUp := Trunc(A+1) ELSE MyRoundUp := Trunc(A) END; FUNCTION MyRoundDown(A : Extended) : Extended; BEGIN IF Trunc(A) = A THEN MyRoundDown := Trunc(A) ELSE IF A < 0 THEN MyRoundDown := Trunc(A-1) ELSE MyRoundDown := Trunc(A); END; BEGIN ReadLn(X0, Y0); ReadLn(X1, Y1); ReadLn(X2, Y2); MinX := X0; IF MinX > X1 THEN MinX := X1; MaxX := X0; IF MaxX < X1 THEN MaxX := X1; MinY := Y0; IF MinY > Y1 THEN MinY := Y1; MaxY := Y0; IF MaxY < Y1 THEN MaxY := Y1; CX := (X0+X1)/2; CY := (Y0+Y1)/2; {Line (X0,Y0) to (X1,Y1)} A := (Y1-Y0); B := (X0-X1); C := X1*Y0-X0*Y1; IF (Y1 <> Y0) THEN BEGIN A0 := B/A; B0 := -1; C0 := CY-A0*CX; END ELSE BEGIN A0 := 1; B0 := 0; C0 := -CX; END; CX := (X0+X2)/2; CY := (Y0+Y2)/2; {Line (X0,Y0) to (X2,Y2)} A := (Y2-Y0); B := (X0-X2); C := X2*Y0-X0*Y2; IF (Y2 <> Y0) THEN BEGIN A1 := B/A; B1 := -1; C1 := CY-A1*CX; END ELSE BEGIN A1 := 1; B1 := 0; C1 := -CX; END; {center} CX := (B0*C1-B1*C0)/(A0*B1-A1*B0); CY := (A1*C0-A0*C1)/(A0*B1-A1*B0); {radius} R := Sqrt(Sqr(X0-CX)+Sqr(Y0-CY)); {Line (X0,Y0) to (X1,Y1)} A := (Y1-Y0); B := (X0-X1); C := X1*Y0-X0*Y1; IF (A*X2+B*Y2+C)*(A*(CX-R)+B*CY+C) > 0 THEN MinX := CX-R; IF (A*X2+B*Y2+C)*(A*(CX+R)+B*CY+C) > 0 THEN MaxX := CX+R; IF (A*X2+B*Y2+C)*(A*CX+B*(CY-R)+C) > 0 THEN MinY := CY-R; IF (A*X2+B*Y2+C)*(A*CX+B*(CY+R)+C) > 0 THEN MaxY := CY+R; MaxX := MyRoundUp(MaxX); MaxY := MyRoundUp(MaxY); MinX := MyRoundDown(MinX); MinY := MyRoundDown(MinY); Write((MaxX-MinX)*(MaxY-MinY):0:0); END. var n:array[1..9,0..1001]of char; b:array[1..9]of byte; textlen:array[1..9]of longint; wypisane,ile:longint; procedure wczytaj; var i,k:longint; zn:char; zb:text; begin {assign(zb,'1253.in'); reset(zb);} readln({zb,}ile); for i:=1 to ile do begin k:=0; read({zb,}zn); while zn<>'#'do begin inc(k); n[i,k]:=zn; read({zb,}zn) end; inc(k); n[i,k]:='#'; readln{(zb)} end; {close(zb)} end; procedure dzialaj(x:longint); var i,kt:longint; zn:char; begin i:=1; zn:=n[x,i]; while zn<>'#'do begin if zn='*' then begin kt:=ord(n[x,i+1])-48; i:=i+2; dzialaj(kt) end else begin write(zn); inc(i) end; zn:=n[x,i]; end; end; procedure koniec; begin writeln('#'); halt end; procedure dfsvisit(v:byte); var zn:char; i:integer; begin b[v]:=1; i:=1; textlen[v]:=0; zn:=n[v,i]; while zn<>'#'do begin if ((ord(zn)-48)>0)and((ord(zn)-48)<10)and(n[v,i-1]='*')then begin if b[ord(zn)-48]=1 then begin writeln('#'); halt end else if b[ord(zn)-48]=2 then begin textlen[v]:=textlen[v]+textlen[ord(zn)-48]; if textlen[v]>1000000 then koniec end else if b[ord(zn)-48]=0 then begin dfsvisit(ord(zn)-48); textlen[v]:=textlen[v]+textlen[ord(zn)-48]; if textlen[v]>1000000 then koniec end; inc(i) end else if zn='*'then inc(i) else begin inc(textlen[v]); if textlen[v]>1000000 then koniec; inc(i) end; zn:=n[v,i] end; b[v]:=2; end; procedure dfs; begin fillchar(b,sizeof(b),0); fillchar(textlen,sizeof(textlen),0); dfsvisit(1) end; begin wczytaj; dfs; dzialaj(1); end. I got accepted with your program making FEW modifications: 1) n:array[1..9,0..1001]of char; replaced with n:array[1..9,0..1021]of char; 2) replaced all 48 by ord('0'); 3) In DFSvisit added Next varible: Next := ord(zn)-48 every occurance of ord(zn)-48 replaced by Next this avoided recalculating ord(zn)-48. I got AC after 0.991 second extreme!!! ----- ALMOST YOUR PROGRAM ----- var n:array[1..9,0..1021]of char; b:array[1..9]of byte; textlen:array[1..9]of longint; wypisane,ile:longint; procedure wczytaj; var i,k:longint; zn:char; zb:text; begin readln({zb,}ile); for i:=1 to ile do begin k:=0; read({zb,}zn); while zn<>'#'do begin inc(k); n[i,k]:=zn; read({zb,}zn) end; inc(k); n[i,k]:='#'; readln{(zb)} end; {close(zb)} end; procedure dzialaj(x:longint); var i,kt:longint; zn:char; begin i:=1; zn:=n[x,i]; while zn<>'#'do begin if zn='*' then begin kt:=ord(n[x,i+1])-Ord('0'); i:=i+2; dzialaj(kt) end else begin write(zn); inc(i) end; zn:=n[x,i]; end; end; procedure koniec; begin writeln('#'); halt end; procedure dfsvisit(v:byte); var zn:char; next: Integer; i:integer; begin b[v]:=1; i:=1; textlen[v]:=0; zn:=n[v,i]; while zn<>'#'do begin if ((ord(zn)-Ord('0'))>0)and((ord(zn)-Ord('0'))<10)and(n[v,i-1] ='*')then begin Next := ord(zn)-Ord('0'); if b[Next]=1 then begin writeln('#'); halt end else if b[Next]=2 then begin textlen[v]:=textlen[v]+textlen[Next]; if textlen[v]>1000000 then koniec end else if b[Next]=0 then begin dfsvisit(Next); textlen[v] := textlen[v]+textlen[Next]; if textlen[v]>1000000 then koniec end; inc(i) end else if zn='*'then inc(i) else begin inc(textlen[v]); if textlen[v]>1000000 then koniec; inc(i) end; zn:=n[v,i] end; b[v]:=2; end; procedure dfs; begin fillchar(b,sizeof(b),0); fillchar(textlen,sizeof(textlen),0); dfsvisit(1) end; begin wczytaj; dfs; dzialaj(1); end. > I got accepted with your program making FEW modifications: > > 1) > n:array[1..9,0..1001]of char; > replaced with > n:array[1..9,0..1021]of char; > > 2) replaced all 48 by ord('0'); > > 3) In DFSvisit > added Next varible: Next := ord(zn)-48 > every occurance of ord(zn)-48 replaced by Next > this avoided recalculating ord(zn)-48. > > I got AC after 0.991 second extreme!!! > > ----- ALMOST YOUR PROGRAM ----- > var > n:array[1..9,0..1021]of char; > b:array[1..9]of byte; > textlen:array[1..9]of longint; > wypisane,ile:longint; > > procedure wczytaj; > var > i,k:longint; > zn:char; > zb:text; > begin > readln({zb,}ile); > for i:=1 to ile do > begin > k:=0; > read({zb,}zn); > while zn<>'#'do > begin > inc(k); > n[i,k]:=zn; > read({zb,}zn) > end; > inc(k); > n[i,k]:='#'; > readln{(zb)} > end; > {close(zb)} > end; > > procedure dzialaj(x:longint); > var > i,kt:longint; > zn:char; > begin > i:=1; > zn:=n[x,i]; > while zn<>'#'do > begin > if zn='*' then > begin > kt:=ord(n[x,i+1])-Ord('0'); > i:=i+2; > dzialaj(kt) > end > else > begin > write(zn); > inc(i) > end; > zn:=n[x,i]; > end; > end; > > procedure koniec; > begin > writeln('#'); > halt > end; > > procedure dfsvisit(v:byte); > var zn:char; > next: Integer; > i:integer; > begin > b[v]:=1; > i:=1; > textlen[v]:=0; > zn:=n[v,i]; > while zn<>'#'do > begin > if ((ord(zn)-Ord('0'))>0)and((ord(zn)-Ord('0'))<10)and(n[v,i-1] > ='*')then > begin > Next := ord(zn)-Ord('0'); > > if b[Next]=1 then > begin > writeln('#'); > halt > end > else if b[Next]=2 then > begin > textlen[v]:=textlen[v]+textlen[Next]; > if textlen[v]>1000000 then koniec > end > else if b[Next]=0 then > begin > dfsvisit(Next); > textlen[v] := textlen[v]+textlen[Next]; > if textlen[v]>1000000 then koniec > end; > inc(i) > end > else if zn='*'then inc(i) > else > begin > inc(textlen[v]); > if textlen[v]>1000000 then koniec; > inc(i) > end; > zn:=n[v,i] > end; > b[v]:=2; > end; > > procedure dfs; > begin > fillchar(b,sizeof(b),0); > fillchar(textlen,sizeof(textlen),0); > dfsvisit(1) > end; > > begin > wczytaj; > dfs; > dzialaj(1); > end. > What's wrong var dig : array[2..36] of byte; maxn ,tiv,i: byte; c ,max : char; b : boolean; begin b := True; read(c); repeat if (c > max) then begin max := c; if max in ['A'..'Z'] then maxn := ord(c) - 55 else maxn := ord(c) - 48; end; if c in ['A'..'Z'] then tiv := ord(c) - 55 else tiv := ord(c) - 48; for i := maxn + 1 to 36 do begin if (i <> 1) then dig[i] := (dig[i]*i + tiv) mod (i-1); end; read(c); until not (c in ['0'..'9','A'..'Z']); for i := maxn + 1 to 36 do if (dig[i] = 0) then begin write(i); b := False; break; end; if (b) then writeln('No solution.') end. Here is my program: program conference; const max=1000; var map:array[1..max,1..max] of boolean; link:array[1..max] of longint; cover:array[1..max] of boolean; n,m,k:longint; procedure readdata; var i,j,a,b:longint; begin readln(n,m,k); for i:=1 to k do begin readln(a,b); map[a][b]:=true; end; end; function find(i:longint):boolean; var k,p:longint; begin find:=true; for k:=1 to m do if map[i][k] and not cover[k] then begin p:=link[k];link[k]:=i;cover[k]:=true; if (p=0) or find(p) then exit; link[k]:=p; end; find:=false; end; procedure main; var x:longint; begin for x:=1 to n do begin fillchar(cover,sizeof(cover),0); find(x); end; end; procedure print; var i,j,step:longint; begin step:=0; for i:=1 to m do if link[i]<>0 then inc(step); writeln(n+m-step); end; BEGIN readdata; main; print; END. To the author: How come scanf("%d %d", &N, &M); while (N > 150 || M > 150) printf("muie\n"); gives TLE? The problem text is unclear, the example should have been explained. So please, keep your day job man!! Oh sorry, it gives Output Limit Exceeded (aah you get it) > To the author: > > How come > > scanf("%d %d", &N, &M); > while (N > 150 || M > 150) printf("muie\n"); > > gives TLE? > > The problem text is unclear, the example should have been explained. > So please, keep your day job man!! > > To the author: > > How come > > scanf("%d %d", &N, &M); > while (N > 150 || M > 150) printf("muie\n"); > > gives TLE? > > The problem text is unclear, the example should have been explained. > So please, keep your day job man!! > I agree, the text not complete why there is no information about the maximum number of event time? I used to use it on Timus already including "memory.h", but now I got CE till I included "strings.h", too. Why? > I used to use it on Timus already including "memory.h", but now I got > CE till I included "strings.h", too. Why? > If i remember well in borland C the memmove function is in string.h and memory.h, in linux is in string.h only afaik. Correct me if i'm wrong #include<stdio.h> #include<stdlib.h> int main(){ int n,k,hrs=0,comp=1; int rest; scanf("%d %d",&n,&k); while(comp<=k){ comp*=2; hrs++; } rest=n-comp; hrs+=(rest+k-1)/k; printf("%d",hrs); printf("\n"); } |
|