Mai intai trebuie sa te autentifici.
Cod sursa(job #1573190)
Utilizator | Data | 19 ianuarie 2016 14:40:53 | |
---|---|---|---|
Problema | Garaj | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.8 kb |
#include <cstdio>
using namespace std;
int x,i,n,t,k;
struct rec{ int lo, hi; }st[16000];
int uneste()
{
if (st[k-1].hi + 1 == st[k].lo)
{
st[k-1].hi = st[k].hi;
--k;
return 1;
}
else if (st[k].hi + 1 == st[k-1].lo)
{
st[k-1].lo = st[k].lo;
--k;
return 1;
}
return 0;
}
int main()
{
freopen("reactii.in", "r", stdin);
freopen("reactii.out", "w", stdout);
scanf("%d%d",&n,&t);
for (;t;t--)
{
k=0;
for(i = 1; i <= n; ++i)
{
scanf("%d", &x);
k++;
st[k].lo=x;
st[k].hi=x;
for(;k>1&&uneste(););
}
if(k==1)
printf("1\n");
else printf("0\n");
}
return 0;
}