Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <cmath>
- #include<iomanip>
- #include<map>
- using namespace std;
- const int INF = 1e9, N = 6e5;
- string s, s1;
- int t, i, n ,q,x,k;
- int a[2002][4004];
- map<int, int> cnt;
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cin >> t;
- for (int I = 0; I < t; I++) {
- cin >> n;
- for (i = 0; i < n; i++) {
- cin >> a[i][0];
- }
- for (int step = 0; step < 4002; step++) {
- cnt.clear();
- for (i = 0; i < n; i++) {
- cnt[a[i][step]]++;
- }
- for (i = 0; i < n; i++) {
- a[i][step + 1] = cnt[a[i][step]];
- }
- }
- cin >> q;
- for (i = 0; i < q; i++) {
- cin >> x >> k;
- k = min(k, 4002);
- cout << a[x-1][k] << "\n";
- }
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement