QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#558493 | #7757. Palm Island | hhhhyf | WA | 0ms | 3784kb | C++20 | 1.5kb | 2024-09-11 16:29:54 | 2024-09-11 16:29:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
void print() { cout << '\n'; }
template <typename T, typename...Args>
void print(T t, Args...args) { cout << t << ' '; print(args...); }
using ll = long long;
const int N = 1000001;
int dir[4][2] = {
{1, 0}, {0, 1}, {-1, 0}, {0, -1}
};
template <typename T> bool chmax(T &x, T y) { if (y > x) { x = y; return true; } return false; }
template <typename T> bool chmin(T &x, T y) { if (y < x) { x = y; return true; } return false; }
template <typename T = int>
vector<T> readVector(int n) {
vector<T> a(n);
for(T &x: a) cin >> x, x --;
return a;
}
void solve () {
int n;
cin >> n;
auto a = readVector(n);
vector<int> f(n);
for (int i = 0; i < n; i ++) {
int x;
cin >> x;
x --;
f[x] = i;
}
for (int& x: a) {
x = f[x];
}
int p = 0;
string s;
for (int i = 0; i + 1 < n; i ++) {
while (p != i) {
s += '1';
p = (p + 1) % n;
}
for (int j = 0; j + 1 < n - i; j ++, p ++) {
if (a[j] < a[j + 1]) {
s += '1';
} else {
swap(a[j], a[j + 1]);
s += '2';
}
}
}
cout << s << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t --) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3784kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
22111 21111111111
result:
wrong answer On Case#1: After your operations, a[1] = 1 but a[1] = 2. (test case 1)