QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#742662#7757. Palm Islandqikala7777WA 1ms5784kbC++231.2kb2024-11-13 17:02:282024-11-13 17:02:30

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 17:02:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5784kb
  • [2024-11-13 17:02:28]
  • 提交

answer

//16:35
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef tuple<int,LL,LL> TPL;
typedef pair<LL,LL> PII;
const int N=1e6+7,inf=0x3f3f3f3f;const LL Linf=0x3f3f3f3f3f3f3f3fLL;
LL qsm(LL a,LL b,LL p){LL res=1;while(b){if(b&1)res=res*a%p;a=a*a%p;b>>=1;}return res;}
LL lowbit(LL x){return x&-x;}
int n;
int a[N],b[N];
deque<int>q;
string ans;
void op1(){
    int x=q.front();
    q.pop_front();
    q.push_back(x);
    ans+='1';
}
void op2(){
    int x=q.front();
    q.pop_front();
    int y=q.front();
    q.pop_front();
    q.push_back(y);
    q.push_front(x);
    ans+='2';
}
void solve(){
    cin>>n;
    q.clear();
    ans.clear();
    for(int i=1;i<=n;i++)cin>>a[i],q.push_back(a[i]);
    for(int i=1;i<=n;i++)cin>>b[i];
    for(int i=1;i<=n;i+=2){
        while(q.front()!=b[i]){
            op1();
        }
        while(i+1<=n&&q[1]!=b[i+1]){
            op2();
        }
        op1();
        if(i+1<=n)op1();
    }
    while(q[0]!=b[1]){
        op1();
    }
    cout<<ans<<endl;
}
int main(){
   IOS
   int T=1;
   cin>>T;
    while(T--)solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5592kb

input:

2
3
1 2 3
2 3 1
4
1 2 3 4
2 1 3 4

output:

1111
1221111

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 5784kb

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:

11111
21112211
1121112211
1122111122111
1122111222111
111111
11111
1121111
221111
11111
112111
1121112211
2111
12111
11111111
1121111
111221112211
1111
1111
111221111111111
111221111
11221112211
11121112211
121112211
111221121111111
1111
2111222111
111111111111
111221111
211111
2111
111221112211
121...

result:

wrong answer On Case#20: After your operations, a[3] = 1 but a[3] = 4. (test case 20)