Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Fabio Colaco
- fabiocolaco.net63.net
- https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=423*/
- #include <bits/stdc++.h>
- using namespace std;
- #define MAX 100010
- struct data{
- int n;
- string num;
- } arr[MAX];
- bool cmp (data x, data y)
- {
- if ( x.n < y.n ) return true;
- return false;
- }
- int main()
- {
- int t;
- scanf("%d", &t);
- getchar ();
- while(t--){
- char buffer[MAX];
- gets(buffer); //blank line
- gets(buffer); //first line of the actual input
- char *pnt = strtok(buffer, " "); //parse
- int i = 0;
- while (pnt != NULL){
- arr[i].n = atoi(pnt);
- i++;
- pnt = strtok(NULL, " "); //goto next
- }
- gets(buffer); //second line of the actual input
- pnt = strtok(buffer, " ");
- i = 0;
- while(pnt != NULL){
- arr[i].num = pnt;
- i++;
- pnt = strtok(NULL, " ");
- }
- sort(arr, arr + i, cmp);
- for(int k = 0; k < i; k++)
- cout << arr[k].num << endl;
- if(t) printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement