Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <algorithm>
- #include <string.h>
- #include <stdbool.h>
- #include <math.h>
- #include <vector>
- #include <map>
- #include <set>
- #define pb push_back
- #define ll long long int
- #define ull unsigned long long int
- #define gcd(a,b) __gcd(a,b)
- using namespace std;
- int main()
- {
- //freopen("a.in","r",stdin);
- //freopen("a.out","w",stdout);
- // std::ios_base::sync_with_stdio(false);
- int t,q,num,chk=0,x;
- string s,T="",ch;
- cin>>t;
- while(t--){
- cin.clear();
- cin>>s;
- for(int i=0;i<s.length();i++){
- if(s[i]>='0' && s[i]<='9'){
- num = s[i]-48;
- num--;
- ch.clear();
- ch = T;
- for(int j=1;j<=num;j++){
- T += ch;
- }
- }else{
- T += (char)s[i];
- }
- //cout<<T<<endl;
- }
- //cout<<T<<endl;
- int len = T.size();
- cin>>q;
- while(q--){
- cin>>x;
- if(x>len) cout<<-1<<endl;
- else cout<<T[x-1]<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement