QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#558489 | #7757. Palm Island | hhhhyf | WA | 0ms | 3808kb | C++20 | 1.5kb | 2024-09-11 16:28:26 | 2024-09-11 16:28:26 |
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';
}
}
}
while (p) {
s += '1';
p = (p + 1) % n;
}
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: 100
Accepted
time: 0ms
memory: 3576kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
221111 211111111111
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
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:
121121 121111111111 122112111111 12121121211111111111 12211121111111111111 122112211111 121121 121112111111 112111211111 121121 221121 122112111111 121111 211111 11221112211122111111 121112111111 222112211121 221111 111111111111 21221112211121111111 122112211121 221112111111 212111211121 22211121111...
result:
wrong answer On Case#1: After your operations, a[1] = 3 but a[1] = 2. (test case 1)