我试图解决矩形查询,从2013年12月$问题C $ cChef比赛:
给定一个方阵的N×N,充满整数{1,.. 10}。我们给出了Q(10 ^ 5)查询如下 定的X1,Y1,X2,Y2找到在给定的子矩阵独特的元素的数量。
Given a square matrix N x N, filled with integers from {1,..10}. We are given Q(10^5) queries as follows given x1,y1, x2,y2 find the number of unique elements in the given sub matrix.
限制: N'LT = 300 Q(10 ^ 5) X1< = X< = N Y1< = Y2< = N 期限1秒。
Limits: N <= 300 Q (10^5) x1 <= x2 <= N y1 <= y2 <= N time limit 1 sec.
我曾尝试使用std的方法::的唯一性,但得到TLE ......我的做法是幼稚的设置...从顶部循环从左上到右下的查询,添加元素set..then打印的std :: set.size()。
I have tried an approach using std::set for uniqueness but getting TLE...MY approach is naive...looping from top left to bottom right for a query and adding elements to set..then printing std::set.size().
有两种可能的方法: -
There are two possible approaches :-
解决这个问题你自己,让辛苦赚来的积分。
Solve the problem on your own and get hard earned points.
等待比赛结束,并查看解决方案的社论。
Wait for contest to end and view solutions in editorials.
祝你好运。