ZJANS

c381. 聖經密碼

Easy Last Update: 2026/01/22
字串

解法一

✅ 完整代碼

評分結果(參考) : AC (21ms, 22.3MB)

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    while(cin >> n >> m){
        if(n==0 && m==0) break;
        
        string s, temp;
        for(int i=0; i<n; i++){
            cin >> temp;
            s += temp;
        }
        
        int idx;
        for(int i=0; i<m; i++){
            cin >> idx;
            cout << s[idx-1];
        }
        
        cout << "\n";
    }
    
    return 0;
}