# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
525254 | 2022-02-11T07:59:52 Z | LucaIlie | Cat (info1cup19_cat) | C++17 | 882 ms | 29584 KB |
#include <iostream> #include <vector> #define MAX_N 3000000 using namespace std; int v[MAX_N], p[MAX_N]; vector <pair<int, int>> ans; int main() { int t, n, i; cin >> t; while ( t-- ) { cin >> n; for ( i = 0; i < n; i++ ) { cin >> v[i]; v[i]--; } for ( i = 0; i < n; i++ ) p[v[i]] = i; i = 0; while ( i < n / 2 && v[i] + v[n - 1 - i] == n - 1 ) i++; if ( i < n / 2 ) { cout << "-1\n"; continue; } ans.clear(); for ( i = 0; i < n / 2; i++ ) { if ( v[i] != i ) { ans.push_back( { i + 1, p[i] + 1 } ); p[v[i]] = p[i]; swap( v[i], v[p[i]] ); p[v[i]] = i; } } cout << ans.size() << " " << ans.size() << "\n"; for ( i = 0; i < ans.size(); i++ ) cout << ans[i].first << " " << ans[i].second << "\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 332 KB | Wrong answer |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 904 KB | Output is correct |
2 | Correct | 44 ms | 996 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 332 KB | Wrong answer |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 904 KB | Output is correct |
2 | Correct | 44 ms | 996 KB | Output is correct |
3 | Correct | 878 ms | 28240 KB | Output is correct |
4 | Correct | 853 ms | 27176 KB | Output is correct |
5 | Correct | 882 ms | 29584 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 332 KB | Wrong answer |
2 | Halted | 0 ms | 0 KB | - |