#include<bits/stdc++.h>
using namespace std;
#ifdef ONPC
#include"debug.h"
#else
#define debug(...) 42
#endif
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 15;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
vector<int> ans[MAXN];
struct point {
int x, y;
};
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, q;
cin >> n >> q;
vector<point> a(n);
for (int i = 0; i < n; i++){
cin >> a[i].x >> a[i].y;
}
vector<array<int, 3>> queries(q);
vector<array<int, 3>> queriesA(q);
vector<array<int, 3>> queriesB(q);
for (int i = 0; i < q; i++){
cin >> queries[i][0] >> queries[i][1] >> queries[i][2];
queries[i][2] = max(queries[i][2], queries[i][0] + queries[i][1]);
queriesA[i] = {queries[i][2], queries[i][0], i};
queriesB[i] = {queries[i][2], queries[i][1], i};
}
//sort(all(a));
for (int i = 0; i < q; i++){// solve for b
for (int j = 0; j < n; j++){
if (a[j].x + a[j].y >= queriesA[i][0] && a[j].x < queriesA[i][1]) ans[queriesA[i][2]].pb(j);
}
}
for (int i = 0; i < q; i++){// solve for b
for (int j = 0; j < n; j++){
if (a[j].x + a[j].y >= queriesB[i][0] && a[j].y < queriesB[i][1]) ans[queriesB[i][2]].pb(j);
}
}
for (int i = 0; i < q; i++){// solve for c
for (int j = 0; j < n; j++){
if (a[j].x + a[j].y < queries[i][2]) ans[queriesB[i][2]].pb(j);
}
}
for (int i = 0; i < q; i++){
sort(all(ans[i]));
debug(ans[i]);
}
for (int i = 0; i < q; i++){
cout << n - sz(ans[i]) << endl;
}
}
Compilation message
examination.cpp: In function 'int main()':
examination.cpp:6:20: warning: statement has no effect [-Wunused-value]
6 | #define debug(...) 42
| ^~
examination.cpp:62:3: note: in expansion of macro 'debug'
62 | debug(ans[i]);
| ^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
23948 KB |
Output is correct |
2 |
Correct |
6 ms |
23900 KB |
Output is correct |
3 |
Correct |
5 ms |
23896 KB |
Output is correct |
4 |
Correct |
6 ms |
23900 KB |
Output is correct |
5 |
Correct |
6 ms |
23896 KB |
Output is correct |
6 |
Correct |
6 ms |
23900 KB |
Output is correct |
7 |
Correct |
364 ms |
65720 KB |
Output is correct |
8 |
Correct |
366 ms |
66128 KB |
Output is correct |
9 |
Correct |
369 ms |
65368 KB |
Output is correct |
10 |
Correct |
417 ms |
64848 KB |
Output is correct |
11 |
Correct |
416 ms |
64852 KB |
Output is correct |
12 |
Correct |
358 ms |
63668 KB |
Output is correct |
13 |
Correct |
365 ms |
62364 KB |
Output is correct |
14 |
Correct |
365 ms |
63036 KB |
Output is correct |
15 |
Correct |
367 ms |
62920 KB |
Output is correct |
16 |
Correct |
293 ms |
59984 KB |
Output is correct |
17 |
Correct |
330 ms |
64256 KB |
Output is correct |
18 |
Correct |
181 ms |
70172 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3019 ms |
318256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3019 ms |
318256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
23948 KB |
Output is correct |
2 |
Correct |
6 ms |
23900 KB |
Output is correct |
3 |
Correct |
5 ms |
23896 KB |
Output is correct |
4 |
Correct |
6 ms |
23900 KB |
Output is correct |
5 |
Correct |
6 ms |
23896 KB |
Output is correct |
6 |
Correct |
6 ms |
23900 KB |
Output is correct |
7 |
Correct |
364 ms |
65720 KB |
Output is correct |
8 |
Correct |
366 ms |
66128 KB |
Output is correct |
9 |
Correct |
369 ms |
65368 KB |
Output is correct |
10 |
Correct |
417 ms |
64848 KB |
Output is correct |
11 |
Correct |
416 ms |
64852 KB |
Output is correct |
12 |
Correct |
358 ms |
63668 KB |
Output is correct |
13 |
Correct |
365 ms |
62364 KB |
Output is correct |
14 |
Correct |
365 ms |
63036 KB |
Output is correct |
15 |
Correct |
367 ms |
62920 KB |
Output is correct |
16 |
Correct |
293 ms |
59984 KB |
Output is correct |
17 |
Correct |
330 ms |
64256 KB |
Output is correct |
18 |
Correct |
181 ms |
70172 KB |
Output is correct |
19 |
Execution timed out |
3019 ms |
318256 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |