# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
315117 |
2020-10-22T02:43:19 Z |
2qbingxuan |
Cat (info1cup19_cat) |
C++14 |
|
488 ms |
13592 KB |
#include <bits/stdc++.h>
#ifdef local
#define debug(args...) qqbx(#args, args)
template <typename ...T> void qqbx(const char *s, T ...args) {
int cnt = sizeof...(T);
(std::cerr << "(" << s << ") = (" , ... , (std::cerr << args << (--cnt ? ", " : ")\n")));
}
#else
#define debug(...) ((void)0)
#endif // local
#define pb emplace_back
#define all(v) begin(v), end(v)
using namespace std;
using ll = long long;
void solve() {
int n;
cin >> n;
vector<int> p(n), pos(n/2);
vector<pair<int,int>> ans;
for(int i = 0; i < n; i++) cin >> p[i], --p[i];
for(int i = 0; i < n; i++) if(p[i] < n/2) pos[p[i]] = i;
for(int i = 0; i < n/2; i++) {
if(p[i] != i) {
int j = pos[i];
swap(pos[p[i]], pos[p[j]]);
swap(p[i], p[j]);
swap(p[n-1-i], p[n-1-j]);
ans.pb(i, j);
}
/* for(int j = 0; j < n; j++) cerr << p[j]+1 << (j+1==n ? '\n' : ' '); */
}
if(!is_sorted(all(p))) return cout << -1 << '\n', void();
cout << ans.size() << ' ' << ans.size() << '\n';
for(auto [a, b]: ans) cout << a+1 << ' ' << b+1 << '\n';
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int t;
cin >> t;
while(t--) solve();
}
Compilation message
cat.cpp: In function 'void solve()':
cat.cpp:35:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
35 | for(auto [a, b]: ans) cout << a+1 << ' ' << b+1 << '\n';
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
528 KB |
Output is correct |
2 |
Correct |
23 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
528 KB |
Output is correct |
2 |
Correct |
23 ms |
512 KB |
Output is correct |
3 |
Correct |
488 ms |
12812 KB |
Output is correct |
4 |
Correct |
456 ms |
12320 KB |
Output is correct |
5 |
Correct |
486 ms |
13592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |