# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47571 | dqhungdl | Crazy old lady (IZhO13_crazy) | C++17 | 2 ms | 428 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int T,n,a[1005];
bool Free[1005];
bool Check(int crazyid)
{
for(int i=1;i<=n;i++)
Free[i]=false;
Free[a[1]]=true;
int curid=1;
for(int i=2;i<=n;i++)
{
if(curid==crazyid)
curid++;
if(Free[curid]==false&&a[i]!=curid)
return false;
Free[a[i]]=true;
curid++;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
//freopen("TEST.INP","r",stdin);
//freopen(".OUT","w",stdout);
cin>>T;
while(T--)
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
int res=0;
for(int i=1;i<=n;i++)
res+=Check(i);
cout<<(res==1?1:0)<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |