QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712013 | #7757. Palm Island | tassei903# | WA | 1ms | 3816kb | C++23 | 1.1kb | 2024-11-05 14:17:46 | 2024-11-05 14:17:47 |
Judging History
answer
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define rep(i, l, r) for (int i = l; i < (r); i++)
#define rrep(i, l, r) for(int i = (int)(r)-1; i >= (int)(l); i--)
#define all(x) begin(x), end(x)
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
void solve() {
std::cin.tie(0)->sync_with_stdio(0);
int n;cin >> n;
vector<int> a(n), b(n), c(n);
rep(i, 0, n)cin >> a[i];
rep(i, 0, n)cin >> b[i];
rep(i, 0, n) {
a[i]--;
b[i]--;
c[b[i]] = a[i];
}
// rep(i, 0, n) cout << c[i] << " ";cout << endl;
string ans;
rep(i, 0, n) {
rep(j, 0, n-1) {
if (c[j] > c[j+1]) {
ans += "2";
swap(c[j], c[j+1]);
}
else {
ans += "1";
}
}
ans += "1";
}
// rep(i, 0, n) cout << c[i] << " ";cout << endl;
cout << ans << endl;
}
int main() {
int T;cin >> T;
while (T--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
221111111 2111111111111111
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3564kb
input:
200 3 3 1 2 2 3 1 4 2 4 1 3 2 1 4 3 4 1 4 2 3 2 1 3 4 5 4 3 2 1 5 2 4 5 3 1 5 2 1 5 4 3 5 2 4 1 3 4 4 3 1 2 1 2 4 3 3 1 2 3 3 1 2 4 1 4 2 3 2 1 4 3 4 1 3 2 4 1 4 3 2 3 3 2 1 1 3 2 3 2 3 1 1 3 2 4 1 4 3 2 3 1 2 4 3 1 2 3 1 3 2 3 3 2 1 2 3 1 5 5 1 3 2 4 2 4 5 1 3 4 4 3 1 2 1 4 3 2 4 1 3 4 2 2 4 3 1 3 ...
output:
121211111 2221121121111111 2221111111111111 2222122211121111111111111 2212111211121111111111111 2221221121111111 121211111 2221121111111111 1221111111111111 221111111 211111111 2221221111111111 121111111 121111111 1222112211211111111111111 2221211111111111 2121111111111111 121211111 1111111111111111...
result:
wrong answer On Case#2: After your operations, a[1] = 3 but a[1] = 2. (test case 2)