QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617772 | #7757. Palm Island | Saton | RE | 1ms | 3564kb | C++20 | 3.0kb | 2024-10-06 17:00:58 | 2024-10-06 17:00:59 |
Judging History
answer
///by Saton.
#include<bits/stdc++.h>
#define PI acos(-1)
#define fi first
#define se second
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define LL long long
#define ll __int128
#define DD double double
#define LD long double
#define rep(i,a,b) for(LL i = (a);i <= (b);i ++)
#define lep(i,a,b) for(LL i = (a);i >= (b);i --)
#define FLUSH fflush(stdout)
using namespace std;
const int N = 2e5 + 10,mod = 1e9+7,P = 131;
const LL inf = 1e9+10,INF = 1e18+10;
typedef pair<int,int> PII;
typedef pair<LL,int> PLI;
typedef pair<LL,LL> PLL;
//__builtin_popcountll()计算整数二进制表示中1的个数
// mt19937_64 rnd(random_device{}());
// uniform_int_distribution<LL> dist(0, LLONG_MAX);//dist(rnd)生成随机数
LL n,m,k;
string str;
int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1};
// __int128//最大可用整数类型
// struct Node {
// int l,r;
// bool operator<(const Node &u) const {
// return l < u.l;
// }
// }node[N];
LL qmi(LL a,LL b,LL p) {LL res = 1;while(b) {if(b&1) res = (LL)res*a%p;a = (LL)a*a%p;b >>= 1;}return res%p;}
LL gcd(LL a,LL b) {return b ? gcd(b,a%b) : a;}
LL lcm(LL a,LL b) {return (LL)a*b / gcd(a,b);}
LL lowbit(LL x) {return x & -x;}
void print(ll x) {
if(x<0) putchar('-'),x = -x;
if(x>9) print(x/10);
putchar(x%10+'0');
}
// const int M = 3.2e3 + 10;
// int primses[M],cnt,val[N],res[N];
// bool st[M];
// void gar() {
// for(int i = 2;i <= M;i ++) {
// if(!st[i]) primses[cnt ++] = i;
// for(int j = 0;primses[j]*i <= M;j ++) {
// st[primses[j]*i] = true;
// if(i%primses[j]==0) break;
// }
// }
// }
// const int M = 2e5+10;
// LL fact[M],infact[M];
// void cmb() {
// fact[0] = infact[0] = 1;
// for(int i = 1;i < M;i ++) fact[i] = fact[i-1]*i%mod;
// infact[M-1] = qmi(fact[M-1],mod-2,mod)%mod;
// for(int i = M-2;i >= 0;i --) infact[i] = infact[i+1]*(i+1)%mod;
// }
// LL C(int a,int b) {
// if(a<b) return 0;
// return (LL)fact[a]*infact[b]%mod*infact[a-b]%mod;
// }
void solve() {
cin >> n;
vector<int> a(n),b(n),ls(n);
rep(i,0,n-1) cin >> a[i];
rep(i,0,n-1) cin >> b[i];
rep(i,0,n-1) ls[b[i]] = b[(i+n-1)%n];
vector<int> ans;
rep(i,1,n) {
int t = a[0];
auto pos = find(all(a),ls[t]);
ans.insert(ans.end(),pos-a.begin(),1);
rotate(a.begin(),pos,a.end());
pos = find(all(a),t);
ans.insert(ans.end(),pos-a.begin()-1,2);
rotate(a.begin()+1,pos,a.end());
}
auto pos = find(all(a),b[0]);
ans.insert(ans.end(),pos-a.begin(),1);
rotate(a.begin(),pos,a.end());
for(auto u : ans) cout << u;
cout << '\n';
}
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int T;
cin >> T;
while(T --) {
solve();
}
// solve();
return 0;
}
/* /\_/\
* (= ._.)
* / > \>
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
1111111 122111111111111
result:
ok Correct. (2 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3508kb
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:
11111111 111112111111 112112111111111 112211121112111111111111 112211111112111111111111 11111111111111 11111111 112111111111111 112112111111 11111111 1211111 112112111111111 121111 12111111 11111111111111111111111 112111111111111 1221121111111 1111111 111111111111 1111112211111111111111 112111111111...
result:
ok Correct. (200 test cases)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
200 5 5 1 3 4 2 5 3 2 4 1 5 5 1 2 4 3 3 5 4 1 2 5 1 4 5 3 2 2 5 4 3 1 5 1 5 4 3 2 4 5 2 3 1 5 2 3 4 5 1 5 4 3 2 1 5 1 5 2 4 3 5 3 1 2 4 5 1 2 4 3 5 4 2 3 5 1 5 3 2 1 4 5 4 2 3 1 5 5 3 1 2 5 4 2 4 1 3 5 5 5 3 1 4 2 2 5 4 1 3 5 5 4 3 1 2 2 5 4 1 3 5 3 4 5 2 1 3 5 1 4 2 5 4 5 1 3 2 4 2 3 1 5 5 1 3 4 5 ...
output:
12221112111111111111 111111121112111111111111 111211221112111111111 111211111112111111111 1222112211121111111111 11111122111111111111111 111111111112111111111 12221112111111111111111 1222111111121111111111 111111221112111111111111 111111121111111111111111 11121122111111111111 12221122111211111111 12...
result:
ok Correct. (200 test cases)
Test #4:
score: -100
Runtime Error
input:
100 5 1 2 5 4 3 2 4 5 3 1 6 6 1 5 2 4 3 1 4 5 6 2 3 3 2 1 3 1 2 3 5 5 3 4 2 1 1 2 3 5 4 10 5 9 4 2 6 10 7 8 3 1 1 3 4 10 5 7 2 9 8 6 10 5 9 10 7 8 3 4 6 2 1 2 7 4 3 10 9 5 8 1 6 8 1 7 4 6 3 5 2 8 3 5 1 4 6 8 7 2 4 2 3 4 1 1 4 2 3 7 3 7 4 6 2 1 5 5 6 7 3 4 1 2 8 2 1 4 7 8 3 6 5 5 2 7 4 3 1 8 6 4 3 2 ...