QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#536569 | #7757. Palm Island | XiaoretaW# | WA | 0ms | 3612kb | C++20 | 1.9kb | 2024-08-29 14:38:16 | 2024-08-29 14:38:17 |
Judging History
answer
#include <bits/stdc++.h>
#define debug(...) 42;
#ifdef LOCAL
#include "debug.h"
#endif
using namespace std;
#define V vector
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define F(i, l, r) for (int i = l; i < r; ++i)
#define R(i, l, r) for (int i = r-1; i >= l; --i)
typedef long long LL;
typedef double DB;
typedef pair<int, int> PII;
template<typename T> bool setmin(T &a, T b) { return (a > b ? a = b, 1 : 0); }
template<typename T> bool setmax(T &a, T b) { return (a < b ? a = b, 1 : 0); }
// mt19937_64 rng {chrono::steady_clock::now().time_since_epoch().count()};
/* -------------Main code------------- */
void solve() {
int n; cin >> n;
V<int> a(n), b(n);
F(i, 0, n) cin >> a[i];
V<int> nxt(n + 1);
F(i, 0, n) cin >> b[i];
F(i, 0, n) {
nxt[b[i]] = b[(i + 1) % n];
}
int cur=1;
string ans = "";
F(i, 0, n - 1) {
while (nxt[a[0]] !=a[cur]){
cout<<2;
ans += '2';
cur++;
if(cur==n)cur=1;
}
cout<<1;
ans += '1';
swap(a[0],a[cur]);
cur++;
if(cur==n)cur=1;
}
if(a[0]!=b[0]){
cout<<1;
ans += '1';
while(a[cur]!=b[0]){
cout<<1;
ans += 1;
cur++;
if(cur==n)cur=1;
}
}
// for (char i : ans) {
// if (i == '1') {
// int t = a[0];
// a.erase(a.begin());
// a.push_back(t);
// } else {
// int t = a[1];
// a.erase(a.begin() + 1);
// a.push_back(t);
// }
// }
// assert(a == b);
cout<<'\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int tt; cin >> tt;
while (tt--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3520kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
1111 2111
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
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:
11 21212111 22111 2221121221 2212122121 111111 11 12121 221111 11 21111 22111 2111 211 11111111 12121 22121211 1111 1111 211212211 12121111 2212121111 2111111 121211 2221221211111 1111 2121221211 12212111111 12121111 211111 2111 22121211 211 221111 2211212211 2221212212111 211 22111 22111111 111 221...
result:
wrong answer On Case#2: After your operations, a[2] = 4 but a[2] = 1. (test case 2)