Submission #1119026

#TimeUsernameProblemLanguageResultExecution timeMemory
1119026TsaganaCrazy old lady (IZhO13_crazy)C++14
100 / 100
10 ms596 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); using namespace std; void solve () { int a[1001]; int s[1001]; int r = 0; int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) s[j] = 0; s[a[0]] = 1; int j; for (j = 1; j < n; j++) { int k = j + (j >= i ? 1 : 0); if (!s[k] && a[j] != k) break; s[a[j]] = 1; } if (j == n) r = (r ? -1 : i); } cout << max(r, 0) << '\n'; } int main() {IOS int t; cin >> t; while (t--) solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...