oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

cmi Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

cmi.html

Chuan the Qi Shen (棋神) has decided to participate in the Chessboard-Model Imaging (CMI) competition! Basically, he has to submit an image of size w x h made of only the colors black and white. As Chuan is lazy, he opens up Paint and randomly draws in M black rectangles.

Now, he is happy with the end-product and has decided to submit the image. However, he is curious, how many separate white regions are there in the image?

Input

The first line contains two space-separated integers w and h (1 ≤ w, h ≤ 1,000,000).
The second line contains one integer M (1 ≤ M ≤ 1,000).
The next M lines contain four integers x1, y1, x2 and y2 (0 ≤ x1 < x2 ≤ w, 0 ≤ y1 < y2 ≤ h).
Note that the bottom left corner is (0,0) and the top right corner is (w,h).

Output

Output the number of separate white regions.

Grading

For 30% of test data, w, h and n ≤ 100.

Sample Input 1

15 6
10
1 4 5 6
2 1 4 5
1 0 5 1
6 1 7 5
7 5 9 6
7 0 9 2
9 1 10 5
11 0 14 1
12 1 13 5
11 5 14 6

Sample Output 1

5

Sample Input 2

8 8
3
0 0 4 4
4 4 8 8
1 1 2 2

Sample Output 2

2

Tags

Ad Hoc

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100201s32MBAverage
2021s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o cmi -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.