QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#666149 | #6838. Assumption is All You Need | wdw | WA | 1ms | 3560kb | C++20 | 1.5kb | 2024-10-22 16:50:58 | 2024-10-22 16:51:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
const int N = 3e4 + 10;
const int mod = 1e9 + 7;
const double eps = 1e-10;
using i64 = int64_t;
void solve() {
int n;
cin >> n;
vector<int> a(n + 5), b(n + 5);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
vector<pair<int, int>> ans;
for (int i = 1; i <= n; i++) {
if (a[i] == b[i])continue;
int w1 = 0;
for (int j = n; j >= i; j--) {
if (w1 != 0) {
if (a[j] == b[j])continue;
if (a[j] > b[i]) {
swap(a[j], a[w1]);
ans.push_back({j, w1});
w1 = j;
}
}
if (w1 == 0) {
if (a[j] == b[i]) {
w1 = j;
}
}
}
}
int f = 0;
for (int i = 1; i <= n; i++) {
if (a[i] != b[i]) {
f = 1;
break;
}
}
if (f) {
cout << -1 << '\n';
return;
}
cout << ans.size() << '\n';
for (auto j: ans) {
cout << j.first << " " << j.second << '\n';
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
t = 1;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
input:
3 2 1 2 2 1 4 4 1 2 3 1 3 2 4 8 8 7 6 5 4 3 2 1 1 8 7 6 5 4 3 2
output:
-1 2 1 2 2 4 7 7 8 6 7 5 6 4 5 3 4 2 3 1 2
result:
ok T=3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3560kb
input:
315 10 8 4 6 1 2 9 7 5 10 3 6 7 8 10 5 1 3 2 9 4 10 10 8 2 9 6 5 7 4 3 1 7 1 3 5 9 8 4 10 6 2 6 4 6 5 3 1 2 1 5 4 6 2 3 12 5 9 12 8 10 6 11 4 2 3 1 7 9 2 3 1 5 12 4 7 6 10 8 11 10 4 7 3 2 8 9 6 10 5 1 1 4 8 10 3 7 9 6 2 5 7 1 2 4 5 6 7 3 4 3 5 6 7 2 1 3 1 3 2 2 1 3 7 1 5 3 7 6 4 2 6 5 2 1 3 4 7 1 1 ...
output:
-1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 4 5 2 4 1 2 -1 -1 -1 -1 -1 -1 0 0 -1 -1 -1 -1 -1 -1 0 0 -1 -1 0 -1 -1 -1 1 1 2 -1 2 1 2 2 3 -1 -1 0 -1 -1 2 2 3 3 4 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 1 1 ...
result:
wrong answer Case #2: Jury has the answer but participant has not