| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 477372 | ogibogi2004 | Crazy old lady (IZhO13_crazy) | C++14 | 19 ms | 340 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1024;
int t;
int a[MAXN];
bool taken[MAXN];
void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    set<int>possible;
    for(int lady=1;lady<=n;lady++)
    {
        memset(taken,0,sizeof(taken));
        taken[a[1]]=1;
        bool ok=1;
        for(int j=1;j<lady;j++)
        {
            if(taken[j]==0&&a[j+1]!=j)
            {
                ok=0;break;
            }
            taken[a[j+1]]=1;
        }
        for(int j=lady+1;j<=n;j++)
        {
            if(taken[j]==0&&a[j]!=j)
            {
                ok=0;break;
            }
            taken[a[j]]=1;
        }
        if(ok)possible.insert(lady);
    }
    if(possible.size()==1)
    {
        cout<<(*possible.begin())<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
}
int main()
{
    cin>>t;
    while(t--)solve();
return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
