#include<bits/stdc++.h>
#define MASK(i) (1 << (i))
#define pub push_back
#define all(v) v.begin(), v.end()
#define compact(v) v.erase(unique(all(v)), end(v))
#define pii pair<int,int>
#define fi first
#define se second
#define endl "\n"
#define sz(v) (int)(v).size()
#define dbg(x) "[" #x " = " << (x) << "]"
using namespace std;
template<class T> bool minimize(T& a, T b){if(a > b) return a = b, true;return false;}
template<class T> bool maximize(T& a, T b){if(a < b) return a = b, true;return false;}
typedef long long ll;
typedef long double ld;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rand(ll l, ll r){return uniform_int_distribution<ll>(l, r)(rng);}
const int N = 1e5 + 15;
struct rect{
int x1, y1, x2, y2;
rect() : x1(0), y1(0), x2(0), y2(0) {}
rect(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};
struct point{
int x, y, col;
point() : x(0), y(0), col(0) {}
point(int x, int y, int col) : x(x), y(y), col(col) {}
};
int n, m;
rect a[N];
point b[N];
set<int> s[N];
bool inside(rect a, point b){
return a.x1 <= b.x && b.x <= a.x2 && a.y1 <= b.y && b.y <= a.y2;
}
void solve(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
int x, y, u, v; cin >> x >> y >> u >> v;
a[i] = rect(x,y,u,v);
}
for(int i = 1; i <= m; i++){
int x, y, col; cin >> x >> y >> col;
b[i] = point(x,y,col);
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(inside(a[i], b[j])) s[i].insert(b[j].col);
}
}
for(int i = 1; i <= n; i++) cout << sz(s[i]) << endl;
}
signed main(){
ios_base::sync_with_stdio(NULL);
cin.tie(0); cout.tie(0);
#define task "task"
if(fopen(task".INP", "r")){
freopen(task".INP", "r", stdin);
freopen(task".ANS", "w", stdout);
}
int t; t = 1; //cin >> t;
while(t--) solve();
}
Compilation message (stderr)
plahte.cpp: In function 'int main()':
plahte.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
77 | freopen(task".INP", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
plahte.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
78 | freopen(task".ANS", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |