#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char str[100000];
struct a
{
int index;
string number;
} arr[10000];
bool cmp(a lhs,a rhs)
{
if(lhs.index<rhs.index)
{
return true;
}
return false;
}
int main()
{
long long int num,cnt=0,len,i,j,t,len1;
string str1;
scanf("%lld",&t);
while(t--)
{
getchar();
getchar();
gets(str);
len=strlen(str);
j=0;
i=0;
while(str[i]!='\0')
{
num=0;
while(str[i]!=' '&&str[i]!='\0')
{
num=num*10+str[i]-48;
i++;
}
i++;
arr[j].index=num;
j++;
}
len1=j;
j=0;
for(i=0; i<len1; i++)
{
cin>>str1;
arr[j].number=str1;
j++;
}
sort(arr,arr+j,cmp);
if(cnt!=0)
{
cout<<endl;
}
cnt=1;
for(i=0; i<j; i++)
{
cout<<arr[i].number<<endl;
}
memset(str,'\0',sizeof(str));
}
return 0;
}
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char str[100000];
struct a
{
int index;
string number;
} arr[10000];
bool cmp(a lhs,a rhs)
{
if(lhs.index<rhs.index)
{
return true;
}
return false;
}
int main()
{
long long int num,cnt=0,len,i,j,t,len1;
string str1;
scanf("%lld",&t);
while(t--)
{
getchar();
getchar();
gets(str);
len=strlen(str);
j=0;
i=0;
while(str[i]!='\0')
{
num=0;
while(str[i]!=' '&&str[i]!='\0')
{
num=num*10+str[i]-48;
i++;
}
i++;
arr[j].index=num;
j++;
}
len1=j;
j=0;
for(i=0; i<len1; i++)
{
cin>>str1;
arr[j].number=str1;
j++;
}
sort(arr,arr+j,cmp);
if(cnt!=0)
{
cout<<endl;
}
cnt=1;
for(i=0; i<j; i++)
{
cout<<arr[i].number<<endl;
}
memset(str,'\0',sizeof(str));
}
return 0;
}
0 comments: (+add yours?)
Post a Comment