QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#655863 | #7757. Palm Island | anlanyi | TL | 0ms | 9308kb | C++20 | 1.2kb | 2024-10-19 10:02:40 | 2024-10-19 10:03:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
using ll=long long ;
int a[N],b[N];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n,T;
cin >> T;
while(T--){
cin >> n;
queue<int >w;
for(int i=1;i<=n;i++){
cin >> a[i];
w.push(a[i]);
}
for(int i=1;i<=n;i++){
cin >> b[i];
}
vector<vector<int >>vis(1010,vector<int >(1010));
int cnt=0;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++){
if(b[i]>b[j])vis[b[j]][b[i]]=1,cnt++;
}
while(cnt){
int x=w.front();w.pop();
int y=w.front();w.pop();
if(vis[x][y]){
cout<<21;
cnt--;
vis[x][y]=0;
w.push(y);
w.push(x);
}else {
cout<<11;
w.push(x);
w.push(y);
}
}
while(w.front()!=b[1]){
cout<<1;
int t=w.front();
w.pop();
w.push(t);
}
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 9308kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
211121 2111
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Time Limit Exceeded
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:
1111211121 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...