Task: | Numerot |
Sender: | ArktinenKarpalo |
Submission time: | 2020-10-16 19:29:33 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.31 s | 1, 2, 3 | details |
#2 | RUNTIME ERROR | 0.01 s | 2, 3 | details |
#3 | RUNTIME ERROR | 0.01 s | 3 | details |
Code
#include <bits/stdc++.h> #define ll long long #define ld long double #define M 1000000007 #define N (1<<18) using namespace std; int n, t, a[1010], r[1010]; void asdfasdf(vector<pair<int,int>> *ans, int k1, int k2) { ans->push_back(make_pair(k1, k2)); swap(r[a[k1]], r[a[k2]]); swap(a[k1], a[k2]); } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(); cin >> t; for(int g=0; g<t; g++) { cin >> n; for(int i=1; i<=n; i++) { cin >> a[i]; r[a[i]] = i; } if(n == 1) { cout << 0; cout << "\n"; } else if(n == 2) { if(a[1] != 1) cout << -1; else cout << 0; cout << "\n"; } else if(n == 3) { if(a[2] == 2) { if(a[1] == 1) { cout << 0; } else { cout << "1\n1 3"; } } else { cout << -1; } cout << "\n"; } else { vector<pair<int,int>> ans; if(a[1] != 1) { if(r[1] < 3) { asdfasdf(&ans, r[1], n); } asdfasdf(&ans, r[1], 1); } if(a[2] != 2) { if(r[2] < 4) { asdfasdf(&ans, r[2], n); } asdfasdf(&ans, r[2], 2); } for(int i=3; i<=n; i++) { int tmp1 = r[i]; asdfasdf(&ans, r[i], 1); asdfasdf(&ans, r[i], i); asdfasdf(&ans, tmp1, 1); } cout << ans.size() << "\n"; for(auto u:ans) cout << u.first << " " << u.second << "\n"; } } }
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
1000 1 2 3 4 ... |
correct output |
---|
1 10 11 20 22 ... |
user output |
---|
0 -1 19 0 7 0 1 ... Truncated |
Test 2
Group: 2, 3
Verdict: RUNTIME ERROR
input |
---|
1000 224995 413660 249827 2125 ... |
correct output |
---|
1731724 3216040 1940719 14585 532612 ... |
user output |
---|
(empty) |
Test 3
Group: 3
Verdict: RUNTIME ERROR
input |
---|
1000 627887018110416188 785474884983906653 653772166720939773 784335285960673683 ... |
correct output |
---|
5530371754830260284 6918696171534226533 5757755627065159149 6908439780325129803 3223801064342340738 ... |
user output |
---|
(empty) |