Cod sursa(job #2557975)

Utilizator vladsfStirbu Vlad Florin vladsf Data 26 februarie 2020 10:29:49
Problema Nivele Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.01 kb
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>

using namespace std;

ifstream f("nivele.in");
ofstream g("nivele.out");

// Seria borderlands e cea mai naspa din toata istoria gaming-ului, can't change my mind

stack <int> steve;

int main()
{
    int ciururi;
    f>>ciururi;
    for (int i = 1; i <= ciururi; i++)
    {
        int n,x;
        f>>n;
        for (int j = 1; j <= n; j++)
        {
            f>>x;
            steve.push(x);
        }
        int el1,el2,ok=1;
        while (steve.top() != 1)
        {
            el1=steve.top();
            steve.pop();
            el2=steve.top();
            steve.pop();
            if (el1 == el2)
            {
                steve.push(el1-1);
            }
            else
            {
                ok=0;
                break;
            }
        }
        if (steve.top() == 1 && steve.size() == 1)
            g<<"DA";
        else
            g<<"NU";
        g<<'\n';
    }
    return 0;
}