QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627752 | #7757. Palm Island | 53Dawns | WA | 1ms | 3596kb | C++23 | 1.7kb | 2024-10-10 17:02:29 | 2024-10-10 17:02:31 |
Judging History
answer
#include <bits/stdc++.h>
// #include <bits/extc++.h>
#pragma GCC optimize (1)
#pragma GCC optimize (2)
#pragma GCC optimize (3)
// #define int long long
#define IOS ios::sync_with_stdio(0),cin.tie(0)
// using namespace __gnu_pbds;
using namespace std;
const int N=2e5+10,M=1e6+10,mod=1e9+7;
int n;
map<int,int>mp;
void f1() {
for(int i = 1 ; i <= n ; i++) {
mp[i]--;
if(mp[i] == 0) mp[i] = n;
}
}
void f2() {
for(int i = 1 ; i <= n ; i++) {
if(mp[i] == 1) continue;
mp[i]--;
if(mp[i] == 1) mp[i] = n;
}
}
void sol(int cases) {
cin >> n;
std::vector<int> a(n+1);
mp.clear();
for(int i = 1 ; i <= n ; i++) {
cin >> a[i];
mp[a[i]] = i;
}
std::vector<int> b(n+1);
for(int i = 1 ; i <= n ; i++) {
cin >> b[i];
}
std::vector<int> ans;
while(mp[b[1]] != 1) {
f1();
ans.push_back(1);
}
for(int i = 1 ; i <= n - 1; i++) {
int u = mp[b[i]];
int v = mp[b[i+1]];
while(mp[b[i+1]] != 2) {
ans.push_back(2);
f2();
}
ans.push_back(1);
f1();
}
while(1) {
int ff = 1;
for(int i = 1 ; i <= n ; i++) {
if(mp[i] != b[i]) ff = 0;
// cout << mp[i] << " ";
}
// cout << endl;
if(ff == 0) {
ans.push_back(1);
f1();
}else{
break;
}
}
for(auto x : ans) {
cout << x;
}
cout << endl;
}
signed main(){
IOS;
int t=1;
cin>>t;
for(int i=1;i<=t;++i){
sol(i);
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3596kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
11111 1221111
result:
wrong answer On Case#1: After your operations, a[1] = 3 but a[1] = 2. (test case 1)