Submission #861272

# Submission time Handle Problem Language Result Execution time Memory
861272 2023-10-15T18:47:49 Z Ahmed57 Cat (info1cup19_cat) C++17
3.75 / 100
548 ms 16292 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;
        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;
            }
        }
        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;
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 348 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 348 KB Correctly distinguished between possibility and impossibility
2 Correct 29 ms 860 KB Correctly distinguished between possibility and impossibility
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 348 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 348 KB Correctly distinguished between possibility and impossibility
2 Correct 29 ms 860 KB Correctly distinguished between possibility and impossibility
3 Correct 543 ms 16292 KB Correctly distinguished between possibility and impossibility
4 Correct 529 ms 16212 KB Correctly distinguished between possibility and impossibility
5 Correct 548 ms 16208 KB Correctly distinguished between possibility and impossibility
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 348 KB Wrong answer
2 Halted 0 ms 0 KB -