#46394: today is my birthday


1121226@stu.wghs.tp.edu.tw (Arthur✨EC)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [60.248.154.139]
最後登入時間 :
2025-08-21 12:59:45

#include<bits/stdc++.h>
using namespace std;
int main(){
    string order;
    string s;
    int q;
    cin>>order;
    cin>>s;
    cin>>q;
    // 建立字母順序的映射
    map<char, int> orderMap;
    for(int i=0;i<order.length();i++){
        orderMap[order[i]]=i;
    }
    // 自定義比較函數
    sort(s.begin(), s.end(), [&](char a, char b){
        return orderMap[a]<orderMap[b];
    });
    // 回答查詢
    for(int i=0;i<q;i++){
        int pos;
        cin>>pos;
        cout<<s[pos-1]<<endl;  // 轉換為0-based index
    }
    return 0;
}