Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#define DEBUG //comment when you have to disable all debug macros.
- #include <iostream>
- #include <cstring>
- #include <sstream>
- #include <fstream>
- #include <cstdlib>
- #include <cstdio>
- #include <cmath>
- #include <vector>
- #include <set>
- #include <map>
- #include <bitset>
- #include <climits>
- #include <ctime>
- #include <algorithm>
- #include <functional>
- #include <stack>
- #include <queue>
- #include <list>
- #include <deque>
- #include <sys/time.h>
- #include <iomanip>
- #include <cstdarg>
- #include <utility> //std::pair
- #include <cassert>
- using namespace std;
- // Input macros
- #define s(n) scanf("%d",&n)
- #define sc(n) scanf("%c",&n)
- #define sl(n) scanf("%lld",&n)
- #define sf(n) scanf("%lf",&n)
- #define ss(n) scanf("%s",n)
- //Pair macros
- #define mp make_pair // useful for working with pairs
- #define fi first
- #define se second
- #define ll long long //data types used often, but you don't want to type them time by time_t
- // Useful container manipulation / traversal macros
- #define forall(i,a,b) for(int i=a;i<b;i++)
- #define foreach(v, c) for( typeof( (c).begin()) v = (c).begin(); v != (c).end(); ++v)
- #define all(a) a.begin(), a.end()
- #define in(a,b) ( (b).find(a) != (b).end())
- #define pb push_back
- #ifdef DEBUG
- #define debug(args...) {cerr << #args << ": ";dbg,args; cerr<<endl;}
- #else
- #define debug(args...) // Just strip off all debug tokens
- #endif
- struct debugger
- {
- template<typename T> debugger& operator , (const T& v)
- {
- cerr<<v<<" ";
- return *this;
- }
- } dbg;
- int main()
- {
- int t,i=0;
- string input;
- map<char, long long int> hashChar;
- cin >> t;
- while (i < t)
- {
- hashChar.clear();
- cin >> input;
- int currentIndex = 0;
- long long int p,q,current,hashIndex;
- bool charFound;
- while (currentIndex < input.length())
- {
- if (hashChar.find(input[currentIndex]) != hashChar.end())
- hashChar[input[currentIndex]]++;
- else
- {
- hashChar[input[currentIndex]] = 1;
- }
- currentIndex++;
- }
- cin >> p >> q;
- for (long long int a = 0; a < q; a++)
- {
- cin >> current;
- hashIndex = 1;
- charFound = false;
- for (int b = 0; b < 256; b++)
- {
- if (hashChar.find(b) != hashChar.end())
- {
- hashIndex += hashChar[b]*p;
- if (hashIndex > current)
- {
- printf("%c\n", b);
- charFound = true;
- break;
- }
- }
- }
- if (!charFound)
- {
- printf("-1\n");
- }
- }
- i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement