# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
92654 | SamAnd | 성질 급한 지학이 (IZhO13_crazy) | C++17 | 10 ms | 632 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |