F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Color it

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)
Total Submission(s): 4194    Accepted Submission(s): 1154


Problem Description
Do you like painting? Little D doesn't like painting, especially messy color paintings. Now Little B is painting. To prevent him from drawing messy painting, Little D asks you to write a program to maintain following operations. The specific format of these operations is as follows.

$0$ : clear all the points.

$1$ $x$ $y$ $c$ : add a point which color is $c$ at point $(x,y)$.

$2$ $x$ $y_1$ $y_2$ : count how many different colors in the square $(1,y1)$ and $(x,y2)$. That is to say, if there is a point $(a,b)$ colored $c$, that $1 \leq a \leq x$ and $y_1 \leq b \leq y_2$, then the color $c$ should be counted.

$3$ : exit.
 

Input
The input contains many lines.

Each line contains a operation. It may be '0', '1 x y c' ( $1\leq x,y\leq 10^6,0\leq c \leq 50$ ), '2 x y1 y2' ($1\leq x,y_1,y_2\leq 10^6$ ) or '3'.

$x,y,c,y1,y2$ are all integers.

Assume the last operation is 3 and it appears only once.

There are at most $150000$ continuous operations of operation 1 and operation 2.

There are at most $10$ operation 0.

 

Output
For each operation 2, output an integer means the answer .
 

Sample Input
0 1 1000000 1000000 50 1 1000000 999999 0 1 1000000 999999 0 1 1000000 1000000 49 2 1000000 1000000 1000000 2 1000000 1 1000000 0 1 1 1 1 2 1 1 2 1 1 2 2 2 1 1 2 1 2 2 2 2 1 1 2 1 2 1 3 2 2 1 2 2 10 1 2 2 10 2 2 0 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 2 1 2 2 1 2 1 1 2 1 2 1 1 2 2 1 2 2 10 1 2 2 10 2 2 3
 

Sample Output
2 3 1 2 2 3 3 1 1 1 1 1 1 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-21 17:23:47, Gzip enabled