-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathcpp.cpp
More file actions
55 lines (47 loc) · 1.19 KB
/
cpp.cpp
File metadata and controls
55 lines (47 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<bits/stdc++.h>
using namespace std;
typedef double long dl;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
int mod = 1000000007;
#define int long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)((x).size())
#define endl '\n'
#define all(x) x.begin(), x.end()
#define rep(i,a, n) for(int i=a; i<(n); i++)
template<typename T> void _print(T x) { cout << x << "]" << endl; }
void _print(vll &ans) {for (auto i : ans) cout << i << " "; cout << endl;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x);
#else
#define dbg(x...)
#endif
const int N = 2002;
int a[N][N], s[N];
void solve() {
int n; cin >> n;
rep(i, 0, n) cin >> a[0][i];
rep(i, 0, n) {
rep(j, 0, n + 1) s[j] = 0;
rep(j, 0, n) s[a[i][j]]++;
rep(j, 0, n) {
a[i + 1][j] = s[a[i][j]];
}
}
int q; cin >> q;
while (q--) {
int x, k; cin >> x >> k;
cout << a[min(n, k)][x - 1] << endl;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1;
cin >> t;
while (t--) solve();
return 0;
}
/* random multi-line comment in one line */