# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
92654 | SamAnd | Crazy old lady (IZhO13_crazy) | C++17 | 10 ms | 632 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 <iostream>
#include <algorithm>
using namespace std;
const int N=1003;
void sp();
void fp();
int n;
int a[N];
bool c[N];
int main()
{
//fp();
int tt;
cin>>tt;
for(int ii=0;ii<tt;++ii)
{
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>a[i];
c[i]=false;
}
int ans=0;
for(int i=1;i<=n;++i)
{
for(int i=1;i<=n;++i)
c[i]=false;
c[a[1]]=true;
bool z=true;
for(int j=1,k=2;j<=n,k<=n;++j,++k)
{
if(j==i)
{
--k;
continue;
}
if(a[k]!=j && !c[j])
{
z=false;
break;
}
c[a[k]]=true;
}
if(z && !ans)
ans=i;
else if(z && ans)
{
ans=0;
break;
}
}
cout<<ans<<endl;
}
sp();
return 0;
}
void fp()
{
#ifndef OLYMP
freopen("crazy.in","r",stdin);
freopen("crazy.out","w",stdout);
#endif
}
void sp()
{
#ifdef OLYMP
system("pause");
#endif
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |