# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522292 | amunduzbaev | Cat (info1cup19_cat) | C++17 | 481 ms | 13948 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |