Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program one;
- var
- a:array [1..1000,1..2] of integer;
- i,j,n,k:integer;
- b:array [1..1000] of boolean;
- l,p:integer;
- procedure check;
- var
- i1,i2,i3:integer;
- ar:array[1..1000] of integer;
- c:integer;
- begin
- for i1:=1 to n do
- for i2:=1 to n do
- if (i1<>i2)and(b[i1])and(b[i2]) then
- begin
- for i3:=1 to n do
- begin
- if ((a[i3,1]=i1)and(a[i3,2]=i2))or((a[i3,1]=i2)and(a[i3,2]=i1)) then exit;
- end;
- end;
- c:=0;
- for i1:=1 to n do
- if b[i1] then
- begin
- inc(c);
- ar[c]:=i1;
- end;
- if c=k then
- begin
- for i1:=1 to c do
- begin
- write(ar[i1],' ');
- end;
- halt(0);
- end;
- end;
- begin
- assign(input,'tournament.in');
- assign(output,'tournament.out');
- reset(input);
- rewrite(output);
- readln(n);
- for i:=1 to n do
- read(a[i,1],a[i,2]);
- readln(k);
- fillchar(b,sizeof(b),0);
- l:=1;
- p:=1;
- for i:=1 to n do l:=l*2;
- for i:=1 to l do
- begin
- p:=1;
- if b[p] then
- begin
- while b[p] do
- begin b[p]:=false; inc(p);
- end;
- b[p]:=true;
- end else b[p]:=true;
- check;
- end;
- writeln('0');
- close(input);
- close(output);
- end.
- { NEXT }
- Program tournament;
- var
- n:integer;
- k:integer;
- a:array[1..10000,1..2] of integer;
- b:array[1..10000] of boolean;
- i,j:integer;
- l,c,lgrp:integer;
- g1:array[1..10000,1..2]of integer;
- count:integer;
- gc:array[1..2] of integer;
- function find(group,lastgroup:integer):integer;
- var
- i,ff:integer;
- begin
- for i:=1 to n do
- if b[i]=false then
- if (a[i,1]=group)or(a[i,2]=group) then
- begin
- b[i]:=true;
- if a[i,1]=group then ff:=a[i,2] else ff:=a[i,1];
- inc(gc[lastgroup]);
- g1[gc[lastgroup],lastgroup]:=ff;
- find:=ff;
- exit;
- end;
- find:=0;
- end;
- begin
- assign(input,'tournament.in');
- assign(output,'tournament.out');
- reset(input);
- rewrite(output);
- read(n);
- for i:=1 to n do read(a[i,1],a[i,2]);
- read(k);
- gc[1]:=0;
- gc[2]:=0;
- count:=0;
- l:=1;
- lgrp:=2;
- fillchar(b,sizeof(b),0);
- while count<n do
- begin
- l:=find(l,lgrp);
- if l=0 then
- begin
- for i:=1 to n do if b[i]=false then l:=i;
- end else
- begin
- if lgrp=1 then lgrp:=2 else lgrp:=1;
- inc(count);
- end;
- end;
- if gc[1]>=k then
- begin
- for i:=1 to k do write(g1[i,1],' ');
- end else
- begin
- if gc[2]>=k then
- begin
- for i:=1 to k do write(g1[i,2],' ');
- end else
- begin
- writeln('0');
- end;
- end;
- close(input);
- close(output);
- end.
- { NEXT }
- Program tournament;
- var
- n:integer;
- k:integer;
- a:array[1..10000,1..2] of integer;
- b:array[1..10000] of boolean;
- i,j:integer;
- l,c,lgrp:integer;
- g1:array[1..10000,1..2]of integer;
- count:integer;
- gc:array[1..2] of integer;
- function find(group,lastgroup:integer):integer;
- var
- i,ff:integer;
- begin
- for i:=1 to n do
- if b[i]=false then
- if (a[i,1]=group)or(a[i,2]=group) then
- begin
- b[i]:=true;
- if a[i,1]=group then ff:=a[i,2] else ff:=a[i,1];
- inc(gc[lastgroup]);
- g1[gc[lastgroup],lastgroup]:=ff;
- find:=ff;
- exit;
- end;
- find:=0;
- end;
- begin
- assign(input,'tournament.in');
- assign(output,'tournament.out');
- reset(input);
- rewrite(output);
- read(n);
- for i:=1 to n do read(a[i,1],a[i,2]);
- read(k);
- gc[1]:=0;
- gc[2]:=0;
- count:=0;
- l:=1;
- lgrp:=2;
- fillchar(b,sizeof(b),0);
- while count<n do
- begin
- l:=find(l,lgrp);
- if l=0 then
- begin
- for i:=1 to n do if b[i]=false then l:=i;
- end else
- begin
- if lgrp=1 then lgrp:=2 else lgrp:=1;
- inc(count);
- end;
- end;
- if gc[1]>=k then
- begin
- for i:=1 to k do write(g1[i,1],' ');
- end else
- begin
- if gc[2]>=k then
- begin
- for i:=1 to k do write(g1[i,2],' ');
- end else
- begin
- writeln('0');
- end;
- end;
- close(input);
- close(output);
- end.
- { NEXT }
- Program tournament;
- var
- n:integer;
- k:integer;
- a:array[1..10000,1..2] of integer;
- b:array[1..10000] of boolean;
- i,j:integer;
- l,c,lgrp:integer;
- g1:array[1..10000,1..2]of integer;
- count:integer;
- gc:array[1..2] of integer;
- label
- wri;
- function find(group,lastgroup:integer):integer;
- var
- i,ff:integer;
- begin
- for i:=1 to n do
- if b[i]=false then
- if (a[i,1]=group)or(a[i,2]=group) then
- begin
- b[i]:=true;
- if a[i,1]=group then ff:=a[i,2] else ff:=a[i,1];
- inc(gc[lastgroup]);
- g1[gc[lastgroup],lastgroup]:=ff;
- find:=ff;
- exit;
- end;
- find:=0;
- end;
- begin
- assign(input,'tournament.in');
- assign(output,'tournament.out');
- reset(input);
- rewrite(output);
- read(n);
- for i:=1 to n do read(a[i,1],a[i,2]);
- read(k);
- gc[1]:=0;
- gc[2]:=0;
- count:=0;
- l:=1;
- lgrp:=2;
- fillchar(b,sizeof(b),0);
- while count<n do
- begin
- l:=find(l,lgrp);
- if l=0 then
- begin
- for i:=1 to n do if b[i]=false then l:=i;
- if l=0 then goto wri;
- end else
- begin
- if lgrp=1 then lgrp:=2 else lgrp:=1;
- inc(count);
- end;
- end;
- wri:
- if gc[1]>=k then
- begin
- for i:=1 to k do write(g1[i,1],' ');
- end else
- begin
- if gc[2]>=k then
- begin
- for i:=1 to k do write(g1[i,2],' ');
- end else
- begin
- writeln('0');
- end;
- end;
- close(input);
- close(output);
- end.
- { NEXT }
- Program tournament;
- var
- n:integer;
- k:integer;
- a:array[1..10000,1..2] of integer;
- b:array[0..10000] of boolean;
- i,j:integer;
- l,c,lgrp:integer;
- g1:array[1..10000,1..2]of integer;
- count:integer;
- LL:integer;
- gc:array[1..2] of integer;
- label
- wri;
- function find(group,lastgroup:integer):integer;
- var
- i,ff:integer;
- begin
- for i:=1 to n do
- if b[i]=false then
- if (a[i,1]=group)or(a[i,2]=group) then
- begin
- b[i]:=true;
- if a[i,1]=group then ff:=a[i,2] else ff:=a[i,1];
- inc(gc[lastgroup]);
- g1[gc[lastgroup],lastgroup]:=ff;
- find:=ff;
- exit;
- end;
- find:=0;
- end;
- begin
- assign(input,'tournament.in');
- assign(output,'tournament.out');
- reset(input);
- rewrite(output);
- read(n);
- for i:=1 to n do read(a[i,1],a[i,2]);
- read(k);
- gc[1]:=0;
- gc[2]:=0;
- count:=0;
- l:=1;
- lgrp:=2;
- fillchar(b,sizeof(b),0);
- for LL:=1 to n*n do
- begin
- l:=find(l,lgrp);
- if l=0 then
- begin
- for i:=1 to n do if b[i]=false then l:=i;
- if l=0 then goto wri;
- end else
- begin
- if lgrp=1 then lgrp:=2 else lgrp:=1;
- inc(count);
- end;
- end;
- wri:
- if gc[1]>=k then
- begin
- for i:=1 to k do write(g1[i,1],' ');
- end else
- begin
- if gc[2]>=k then
- begin
- for i:=1 to k do write(g1[i,2],' ');
- end else
- begin
- writeln('0');
- end;
- end;
- close(input);
- close(output);
- end.
- { NEXT }
- Program tournament;
- var
- n:integer;
- k:integer;
- a:array[1..10000,1..2] of integer;
- b:array[0..10000] of boolean;
- i,j:integer;
- l,c,lgrp:integer;
- g1:array[1..10000,1..2]of integer;
- count:integer;
- LL:integer;
- gc:array[1..2] of integer;
- p:integer;
- label
- wri;
- procedure check;
- var
- i1,i2,i3:integer;
- ar:array[1..1000] of integer;
- c:integer;
- begin
- for i1:=1 to n do
- for i2:=1 to n do
- if (i1<>i2)and(b[i1])and(b[i2]) then
- begin
- for i3:=1 to n do
- begin
- if ((a[i3,1]=i1)and(a[i3,2]=i2))or((a[i3,1]=i2)and(a[i3,2]=i1)) then exit;
- end;
- end;
- c:=0;
- for i1:=1 to n do
- if b[i1] then
- begin
- inc(c);
- ar[c]:=i1;
- end;
- if c=k then
- begin
- for i1:=1 to c do
- begin
- write(ar[i1],' ');
- end;
- halt(0);
- end;
- end;
- function find(group,lastgroup:integer):integer;
- var
- i,ff:integer;
- begin
- for i:=1 to n do
- if b[i]=false then
- if (a[i,1]=group)or(a[i,2]=group) then
- begin
- b[i]:=true;
- if a[i,1]=group then ff:=a[i,2] else ff:=a[i,1];
- inc(gc[lastgroup]);
- g1[gc[lastgroup],lastgroup]:=ff;
- find:=ff;
- exit;
- end;
- find:=0;
- end;
- begin
- assign(input,'tournament.in');
- assign(output,'tournament.out');
- reset(input);
- rewrite(output);
- read(n);
- if n<=10 then
- begin
- for i:=1 to n do
- read(a[i,1],a[i,2]);
- readln(k);
- fillchar(b,sizeof(b),0);
- l:=1;
- p:=1;
- for i:=1 to n do l:=l*2;
- for i:=1 to l do
- begin
- p:=1;
- if b[p] then
- begin
- while b[p] do
- begin b[p]:=false; inc(p);
- end;
- b[p]:=true;
- end else b[p]:=true;
- check;
- end;
- writeln('0');
- close(input);
- close(output);
- end else
- begin
- for i:=1 to n do read(a[i,1],a[i,2]);
- read(k);
- gc[1]:=0;
- gc[2]:=0;
- count:=0;
- l:=1;
- lgrp:=2;
- fillchar(b,sizeof(b),0);
- for LL:=1 to n+1000 do
- begin
- l:=find(l,lgrp);
- if l=0 then
- begin
- for i:=1 to n do if b[i]=false then l:=i;
- if l=0 then goto wri;
- end else
- begin
- if lgrp=1 then lgrp:=2 else lgrp:=1;
- inc(count);
- end;
- end;
- wri:
- if gc[1]>=k then
- begin
- for i:=1 to k do write(g1[i,1],' ');
- end else
- begin
- if gc[2]>=k then
- begin
- for i:=1 to k do write(g1[i,2],' ');
- end else
- begin
- writeln('0');
- end;
- end;
- close(input);
- close(output);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement