QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#642158 | #7757. Palm Island | AuroraKelsey | TL | 1ms | 5676kb | C++14 | 962b | 2024-10-15 11:13:08 | 2024-10-15 11:13:09 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <climits>
using namespace std;
const int N = 1000001;
int n;
int a[N], b[N];
map<int, int> mp;
bool check() {
for(int i=1;i<=n;i++)
if(a[i]!=b[i])
return 0;
return 1;
}
int main() {
int t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin>>b[i],mp[b[i]]=i;
int j;
int tmp;
while(1){
if(mp[a[1]]<mp[a[2]]) {
tmp=a[2];
j=2;
cout<<2;
}else{
tmp=a[1];
cout<<1;
j=1;
}
for(int i=j;i<n;i++)
a[i]=a[i+1];
a[n]=tmp;
if(check())break;
}
cout<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5676kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
1 122
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:
212 22222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222...