포럼
문제 ICPC00236

A. Artwork

설명

A template for an artwork is a white grid of \(n \times m\) squares. The artwork will be created by painting \(q\) horizontal and vertical black strokes. A stroke starts from square \((x_1,y_1)\), ends at square \((x_2,y_2)\) (\(x_1=x_2\) or \(y_1=y_2\)) and changes the color of all squares \((x,y)\) to black where \(x_1 \le x \le x_2\) and \(y_1 \le y \le y_2\).

The beauty of an artwork is the number of regions in the grid. Each region consists of one or more white squares that are connected to each other using a path of white squares in the grid, walking horizontally or vertically but not diagonally. The initial beauty of the artwork is \(1\). Your task is to calculate the beauty after each new stroke. Figure illustrates how the beauty of the artwork varies in Sample Input 1.

제약
입력 형식

The first line of input contains three integers \(n\), \(m\) and \(q\) (\(1 \le n,m \le 1000\), \(1 \le q \le 10^4\)).

Then follow \(q\) lines that describe the strokes. Each line consists of four integers \(x_1\), \(y_1\), \(x_2\) and \(y_2\) (\(1 \le x_1 \le x_2 \le n\), \(1 \le y_1 \le y_2 \le m\)). Either \(x_1 = x_2\) or \(y_1 = y_2\) (or both).

출력 형식

For each of the \(q\) strokes, output a line containing the beauty of the artwork after the stroke.

예제 1
입력
4 6 5
2 2 2 6
1 3 4 3
2 5 3 5
4 6 4 6
1 6 4 6
출력
1
3
3
4
3
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2016

평가 및 의견

A. Artwork

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

A. Artwork

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8