# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100648 | cki86201 | Crazy old lady (IZhO13_crazy) | C++11 | 12 ms | 384 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;
int main() {
int T; scanf("%d", &T);
rep(tt, T) {
int N, p[1010];
scanf("%d", &N);
for(int i=1;i<=N;i++) scanf("%d", p+i);
int ans = -1;
for(int i=1;i<=N;i++) {
int chk[1010] = {};
chk[p[1]] = 1;
int m = 1, ok = 1;
for(int j=2;j<=N;j++) {
if(m == i) ++m;
if(chk[m] == 0 && p[j] != m) {
ok = 0; break;
}
chk[p[j]] = 1;
++m;
}
if(!ok) continue;
if(ans == -1) ans = i;
else ans = 0;
}
if(ans == -1) ans = 0;
printf("%d\n", ans);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |