Submission #315115

# Submission time Handle Problem Language Result Execution time Memory
315115 2020-10-22T02:42:27 Z 2qbingxuan Cat (info1cup19_cat) C++14
0 / 100
16 ms 640 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[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 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 384 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 384 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)