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

lightsflip Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

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

lightsflip.html

Problem Description

Jianzhi is preparing Christmas lights for his annual Christmas party. To decorate his backyard, Jianzhi has arranged his lights in an N by M grid. At first, all of Jianzhi's lights are turned off.

As arranging lights are very boring, Jianzhi decides to test out his magical skills. He issues a series of Q spells, and the ith spell toggles all the lights within the rectangle bounded by (Ai, Bi) and (Ci, Di). Jianzhi wants to know, after all spells have been casted, which lights are turned on and which lights are turned off.

Input

The first line of input will contain three integers, N, M and Q.

The next Q lines of input will contain four integers each, Ai, Bi, Ci and Di.

Output

The output should contain N lines with M integers each, representing the configuration of the lights after Jianzhi's spells. A 0 represents a light that is off, and a 1 represents a light that is on.

Limits

For all subtasks: 1 ≤ N, M ≤ 2 000, 1 ≤ Q ≤ 3 000 000, 0 ≤ Ai ≤ Ci < N, 0 ≤ Bi ≤ Di < M.

Subtask 1 (7%): N = 1, Q ≤ 2 000.

Subtask 2 (11%): N = 1, Bi < Dj for all i, j.

Subtask 3 (19%): N = 1.

Subtask 4 (18%): N, M ≤ 50, Q ≤ 2 000.

Subtask 5 (22%): Q ≤ 2 000.

Subtask 6 (14%): Q ≤ 100 000.

Subtask 7 (9%): No additional constraints.

Subtask 8 (0%): Sample Testcases.

Sample Input 1

1 5 3
0 1 0 3
0 2 0 4
0 0 0 0

Sample Output 1

1 1 0 0 1

Sample Input 2

3 3 2
0 1 1 2
1 0 2 1

Sample Output 2

0 1 1
1 0 1
1 1 0

Tags

Ad Hoc

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
17213s256MBMinimum
211203s256MBMinimum
319613s256MBMinimum
418223s256MBMinimum
522623s256MBMinimum
614823s256MBMinimum
791423s256MBMinimum
8023s256MBMinimum

Judge Compile Command

g++-8 ans.cpp -o lightsflip -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.