답안 #861273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
861273 2023-10-15T18:52:34 Z Ahmed57 Cat (info1cup19_cat) C++17
15 / 100
544 ms 17104 KB
#include <bits/stdc++.h>

using namespace std;
int main(){
    int t;cin>>t;
    z:while(t--){
        int n;cin>>n;
        int arr[n+1],pos[n+1];
        for(int i = 1;i<=n;i++){
            cin>>arr[i];pos[arr[i]] = i;
        }
        int g = 0;int lol = 0;
        for(int i = 1;i<=n/2;i++){
            if(arr[i]!=i)g++;
            if(n-arr[i]+1!=arr[n-i+1]){
                cout<<-1<<endl;
                goto z;
            }if(arr[i]>n/2){
                lol++;
            }
        }
        if(lol&1){
            cout<<-1<<endl;
            goto z;
        }
        int e = 0;
        for(int i = 1;i<=n;i++){
            int x = pos[i];
            if(arr[i]==i)continue;
            if(arr[n-i+1]==n-x+1&&arr[n-x+1]==n-i+1&&arr[x]==i){
                e++;
            }
        }
        cout<<g-(e/4)<<" "<<0<<endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 348 KB Correctly distinguished between possibility and impossibility
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 348 KB Correctly distinguished between possibility and impossibility
2 Correct 28 ms 604 KB Correctly distinguished between possibility and impossibility
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 348 KB Correctly distinguished between possibility and impossibility
2 Correct 27 ms 348 KB Correctly distinguished between possibility and impossibility
3 Correct 28 ms 604 KB Correctly distinguished between possibility and impossibility
4 Correct 27 ms 860 KB Correctly distinguished between possibility and impossibility
5 Correct 11 ms 604 KB Correctly distinguished between possibility and impossibility
6 Correct 9 ms 348 KB Correctly distinguished between possibility and impossibility
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 348 KB Correctly distinguished between possibility and impossibility
2 Correct 28 ms 604 KB Correctly distinguished between possibility and impossibility
3 Correct 544 ms 1364 KB Correctly distinguished between possibility and impossibility
4 Correct 511 ms 1372 KB Correctly distinguished between possibility and impossibility
5 Correct 511 ms 1852 KB Correctly distinguished between possibility and impossibility
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 348 KB Correctly distinguished between possibility and impossibility
2 Correct 27 ms 348 KB Correctly distinguished between possibility and impossibility
3 Correct 28 ms 604 KB Correctly distinguished between possibility and impossibility
4 Correct 27 ms 860 KB Correctly distinguished between possibility and impossibility
5 Correct 11 ms 604 KB Correctly distinguished between possibility and impossibility
6 Correct 9 ms 348 KB Correctly distinguished between possibility and impossibility
7 Correct 544 ms 1364 KB Correctly distinguished between possibility and impossibility
8 Correct 511 ms 1372 KB Correctly distinguished between possibility and impossibility
9 Correct 511 ms 1852 KB Correctly distinguished between possibility and impossibility
10 Correct 490 ms 14160 KB Correctly distinguished between possibility and impossibility
11 Correct 498 ms 14620 KB Correctly distinguished between possibility and impossibility
12 Correct 523 ms 17104 KB Correctly distinguished between possibility and impossibility
13 Correct 516 ms 16420 KB Correctly distinguished between possibility and impossibility
14 Correct 526 ms 17072 KB Correctly distinguished between possibility and impossibility