Submission #315327

#TimeUsernameProblemLanguageResultExecution timeMemory
315327Kevin_Zhang_TWCat (info1cup19_cat)C++17
0 / 100
1091 ms384 KiB
#include<bits/stdc++.h> #define pb emplace_back #define AI(i) begin(i), end(i) using namespace std; using ll = long long; #ifdef KEV #define DE(args...) kout("[ " + string(#args) + " ] = ", args) void kout() {cerr << endl;} template<class T1, class ...T2> void kout (T1 v, T2 ...e) { cerr << v << ' ', kout(e...); } template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L)==R], ++L; } #else #define DE(...) 0 #define debug(...) 0 #endif const int MAX_N = 300010; int n; vector<pair<int,int>> op; // just the front half void swap_sort(vector<int> p) { } bool valid(vector<int> p) { int cnt = 0, m = n / 2; for (int l = 0, r = n-1;l < r;++l, --r) { if ((p[l]>m) ^ (p[r]<=m)) return false; if (p[l] > m) ++cnt; } if (cnt & 1) return false; vector<int> pos(n); for (int i = 0;i < n;++i) pos[ p[i] ] = i; auto sw = [&](int x, int y) { swap(p[x], p[y]), swap(pos[ p[x] ], pos[ p[y] ]); }; auto do_op = [&](int x, int y) { int a = x, b = y, c = n - x - 1, d = n - y - 1; sw(a, b), sw(c, d); }; for (int i = 0;i < m;++i) { while (i+1 != p[i]) do_op(i, p[i]); } for (int i = 0;i < n;++i) if (p[i] != i+1) return false; return true; } // make p good enough so that I can do swap sort on it void pair_good(vector<int> &p) { } bool solve() { cin >> n; vector<int> p(n); for (int &i : p) cin >> i; if (!valid(p)) return false; pair_good(p); swap_sort(p); return true; } signed main() { ios_base::sync_with_stdio(0), cin.tie(0); int T; cin >> T; while (T--) { op.clear(); if (!solve()) cout << -1 << '\n'; else { cout << op.size() << ' ' << op.size() << '\n'; for (auto [a, b] : op) cout << a+1 << ' ' << b+1 << '\n'; } } }
#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...