Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- namespace sub_1_2 {
- void solve(int n, int q) {
- vector<int> a(n), b(q);
- for (auto &i : a) cin >> i;
- for (auto &i : b) cin >> i;
- sort(a.begin(), a.end());
- for (auto &i : b) {
- int pos = upper_bound(a.begin(), a.end(), i) - a.begin();
- cout << pos << '\n';
- }
- }
- }
- namespace sub_3_4 {
- void solve(int n, int q, int k) {
- vector<vector<int>> a(n, vector<int>(k)), b(q, vector<int>(k));
- for (auto &i : a) for (auto &j : i) cin >> j;
- for (auto &i : b) for (auto &j : i) cin >> j;
- for (auto &i : b) {
- int cnt = 0;
- for (auto &j : a) {
- bool flag = false;
- for (int l = 0; l < k; l++) {
- if (i[l] < j[l]) {
- flag = true;
- break;
- }
- }
- if (!flag) cnt++;
- }
- cout << cnt << '\n';
- }
- }
- }
- signed main() {
- cin.tie(0)->sync_with_stdio(0);
- int T; cin >> T;
- while (T--) {
- int n, q, k;
- cin >> n >> q >> k;
- if (k == 1 && n <= 100000) sub_1_2::solve(n, q);
- else sub_3_4::solve(n, q, k);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement