Răspuns :
#include <iostream>
using namespace std;
int main() {
int v[50], n, i, ok=0;
//Citire vector
cin >> n;
for (i = 0; i < n; i++) cin >> v[i];
//Parcurgere si testare
for (i = 0; i < n; i++) {
if (v[i] == 1 && ok == 0) ok = 1;
else if (v[i] == 1 && ok == 1) {
cout << "NU";
return 0;
}
else if (v[i] == 0) ok = 0;
}
cout << "Da";
}
#include <iostream>
#include <bitset>
using namespace std;
bitset<1001>c;
int main()
{
int n, i, cifra, alter=1;
cin >> n;
for (i=1; i<=n; ++i)
{
cin >> cifra;
c[i]=cifra;
}
i=1;
while (i<n && alter)
{
if(c[i]*c[i+1]==1) alter=0;
++i;
}
if (alter) cout << "DA";
else cout << "NU";
return 0;
}