Cod sursa(job #18156)

Utilizator portocalaDiculescu Elena Alexandra portocala Data 18 februarie 2007 10:13:17
Problema Amlei Scor 0
Compilator cpp Status done
Runda preONI 2007, Runda 2, Clasa a 10-a Marime 0.78 kb
#include <fstream.h>
int n,u,t,ok1,gas,ok2;
ifstream f("amlei.in");
ofstream g("amlei.out");
int exec()
{int i,j,x;
ok1=0;
for(i=1;i<=u;i++)
 {gas=1;
  for(j=1;j<=n;j++)
  {f>>x;
   if(x<0){j++;
	   while(j<=n) {f>>x;j++;}
	   gas=0;
	  }
  }
  if(gas){i++;
	  while(i<=u)
	   {j=1;
	    while(j<=n){f>>x;
			j++;
		       }
	    i++;
	   }
	  ok1=1;
	 }
 }
ok2=0;
for(i=1;i<=t;i++)
 {gas=1;
  for(j=1;j<=n;j++)
  {f>>x;
   if(x<0){j++;
	   while(j<=n) {f>>x;j++;}
	   gas=0;
	  }
  }
  if(gas){i++;
	  while(i<=t){j=1;
		      while(j<=n){f>>x;
				  j++;
				 }
		      i++;
		     }
	  ok2=1;
	 }
 }
return (ok1==ok2);
}
int main()
{while(f>>n>>u>>t)
   if(exec())g<<"DA"<<'\n';
    else g<<"NU"<<'\n';
f.close();
g.close();
return 0;
}