Submission #861263

#TimeUsernameProblemLanguageResultExecution timeMemory
861263Ahmed57Cat (info1cup19_cat)C++17
0 / 100
28 ms860 KiB
#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)^(arr[n-i+1]==n-i+1)){ cout<<-1<<endl; goto z; } if(arr[i]!=i)g++; } int e = 0; for(int i = 1;i<=n;i++){ int x = pos[i]; if(arr[n-i+1]==n-x+1&&arr[n-x+1]==n-i+1){ e++; } } cout<<g-(e/4)<<" "<<0<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...