Cod sursa(job #467721)

Utilizator andrei.dAndrei Diaconeasa andrei.d Data 30 iunie 2010 00:09:27
Problema Nivele Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.95 kb
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>

using namespace std;

#define file_in "nivele.in"
#define file_out "nivele.out"

#define nmax 55555

long int T,i,st[nmax],x,n;

void citire()
{
    freopen(file_in,"r",stdin);
    freopen(file_out,"w",stdout);

    scanf("%d", &T);

}

void solve()
{
     while(T--)
     {
         st[0]=0;
         scanf("%d", &n);
         for (i=1;i<=n;++i)
         {
              scanf("%d", &x);
              st[++st[0]]=x;
              while(st[0]>1 && st[st[0]]==st[st[0]-1])
              {
                  st[0]--;
                  st[st[0]]--;
              }
         }
              if (!(st[0]==1 && st[1]==1))
                  printf("NU\n");
                  else
                  printf("DA\n");
         }

}

int main()
{
    citire();
    solve();

    fclose(stdin);
    fclose(stdout);

    return 0;
}