Submission #522292

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5222922022-02-04 13:57:41amunduzbaevCat (info1cup19_cat)C++17
51.25 / 100
481 ms13948 KiB
#include "bits/stdc++.h"
using namespace std;
#define ar array
typedef long long ll;
void solve(){
int n; cin>>n;
vector<int> a(n), pos(n);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) pos[--a[i]] = i;
vector<ar<int, 2>> res;
auto add = [&](int i, int j){
int i_ = n - i - 1, j_ = n - j - 1;
assert(j != i_);
swap(a[i], a[j]);
swap(pos[a[i]], pos[a[j]]);
res.push_back({i, j});
swap(a[i_], a[j_]);
swap(pos[a[i_]], pos[a[j_]]);
};
//~ int cnt = 0;
for(int i=0;i<n/2;i++){
if(a[i] == i){
if(a[n - i - 1] != n - i - 1) { cout<<-1<<"\n"; return; }
continue;
}
int j = pos[i];
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...