# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
546229 | sidon | 성질 급한 지학이 (IZhO13_crazy) | C++17 | 31 ms | 352 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int T; cin >> T;
while(T--) {
int N; cin >> N;
int p[N]; for(int &i : p) cin >> i, --i;
int ans = N;
for(int i = N; i--; ) {
bool vis[N] {}, ok = 1;
vis[*p] = 1;
for(int j = 1; j < N; vis[p[j++]] = 1) {
int k = j - (j <= i);
if(!vis[k] && p[j] != k) ok = 0;
}
if(ok && ans >= 0)
ans = ans == N ? i : -1;
}
cout << (ans % N) + 1 << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |