Cod sursa(job #3159533)

Utilizator profinfo114Prof Info profinfo114 Data 21 octombrie 2023 15:41:50
Problema Nivele Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.74 kb
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
#define DIM 50002
using namespace std;
ifstream fin("nivele.in");
ofstream fout("nivele.out");
int T, nf, v, i, x, j, k, S[DIM];
char sol[200000];
int main(){
    fin >> T;
    for(i = 1; i <= T; i++){
        fin >> nf >> S[1];
        v = 1;
        for(j = 2; j <= nf; j++){
            fin >> x;
            while(S[v] == x)
                v--, x--;
            S[++v] = x;
        }
        if(v == 1 && S[1] == 1){
            sol[k++] = 'D';
            sol[k++] = 'A';
            sol[k++] = '\n';
        }else{
            sol[k++] = 'N';
            sol[k++] = 'U';
            sol[k++] = '\n';
        }
    }
    sol[k] = 0;
    fout << sol;
    return 0;
}