# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101050 | choikiwon | Crazy old lady (IZhO13_crazy) | C++17 | 18 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int MN = 1010;
int N;
int P[MN];
void main2() {
scanf("%d", &N);
for(int i = 0; i < N; i++) {
scanf("%d", &P[i]);
P[i]--;
}
int ans = -1;
for(int i = 0; i < N; i++) {
vector<int> chk(N, 0);
chk[ P[0] ] = 1;
int t = i != 0, ok = 1;
for(int j = 1; j < N; j++) {
if(j - t == i) t = 0;
//cout << i << ' ' << j - t << endl;
if(!chk[j - t] && P[j] != j - t) {
ok = 0;
break;
}
chk[ P[j] ] = 1;
}
if(ok) {
if(ans == -1) ans = i;
else {
ans = -1;
break;
}
}
}
if(ans == -1) printf("0\n");
else printf("%d\n", ans + 1);
}
int TC;
int main() {
scanf("%d", &TC);
while(TC--) main2();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |