Inbox for mugurel_ionut@yahoo.com    Yahoo! - My Yahoo!     Options - Sign Out - Help
Mail    Addresses    Calendar    Notepad   

Paid Net2phone Advertisement - Click Here!
Paid Net2phone Advertisement - Click Here!
Download Attachments
    Prev | Next | Inbox
Reply-to: olimpiada <olimpiada@listbot.com>
Date: Sun, 18 Mar 2001 20:58:41 +0200
From: Mihail Popa <mpopa@fx.ro>  | Block Address | Add to Address Book
To: olimpiada <olimpiada@listbot.com>
Subject: Re: [olimpiada] O problemutza

olimpiada - http://www.olimpiada.home.ro

--------------------------- ListBot Sponsor --------------------------
Start Your Own FREE Email List at http://www.listbot.com/links/joinlb
----------------------------------------------------------------------

uite rezolvarea mea. N-am prea testat-o da' zic ca merge. Face o groaza
de miscari in plus, da' e foarte simplu. Ai teste? Daca da trimite-le

mihai



______________________________________________________________________
To unsubscribe, write to olimpiada-unsubscribe@listbot.com

#include<stdio.h>

int a[11][12],b[11][11],nm,n;
FILE* f;

void push(int t,int k){a[t][++a[t][0]]=k;b[t][k]++;}
int pop(int t){int k=a[t][a[t][0]--];b[t][k]--;a[t][a[t][0]+1]=0;return 
k;}
void move(int i,int j){int k=pop(i);push(j,k);fprintf(f,"%d %d 
%d\n",k,i+1,j+1);nm++;}

void pune(int k,int t)
{
	int i,m,l,s;
   if(b[t][k])
   	{
kkt:
			if(a[t][k]==k)return;
         if(t==1)m=0;
         else m=1;
         move(m,n);
         s=0;
         for(i=n;i>=k;i--)
         	if(a[t][i]==k && !s){move(t,m);s=1;}
            else move(t,n);
         move(m,t);
         for(i=1;i<n-k+1;i++)move(n,t);
         move(n,m);
      }
   else
   	{
      	for(i=0;i<n;i++)
         	if(b[i][k]>1 || (b[i][k]==1 && a[i][k]!=k)){l=i;break;}
         for(i=n;i;i--)
         	{
            	if(a[l][i]==k){move(l,n);break;}
               else move(l,n);
            }
         move(t,l);move(n,t);
         while(a[n][0])move(n,l);
         goto kkt;
      }
}

void main(void)
{
	int i,j,k;
   f=fopen("date","rt");fscanf(f,"%d",&n);
   for(i=0;i<n;i++)for(j=0;j<n;j++){fscanf(f,"%d",&k);push(i,k);}
   fclose(f);f=fopen("rez","wt");
   for(j=1;j<=n;j++)for(i=0;i<n;i++)
   	if(a[i][j]!=j)pune(j,i);
   fprintf(f,"%d",nm);fclose(f);
}

     Prev | Next | Inbox
Download Attachments

Yahoo! Messenger - Send instant messages to friends!
Address Book · Alerts · Auctions · Bill Pay · Bookmarks · Briefcase · Broadcast · Calendar · Chat · Classifieds · Clubs · Companion · Domains · Experts ·Games · Greetings · Home Pages · Invites · Mail · Maps · Member Directory · Messenger · My Yahoo! · News · PayDirect · People Search · Personals · Photos · Shopping · Sports · Stock Quotes · TV · Travel · Weather · Yahooligans · Yellow Pages · more...

Privacy Policy- Terms of Service - Guidelines
Copyright © 1994-2001 Yahoo! Inc. All rights reserved.