ACM night simulation also mad ft

xiaoxiao2021-03-06  79

Oh, there is a flower and can't open it, and you will be unhappy. . . F question (pku1899) actually found a three-character BUG for 4 hours, or three people watch together. . . And C questions (PKU1886) actually wrote it, and I was AC. . . It's too uncomfortable. If you can't see it next time, you should be separated, and you can't find 5 hours, so you die very miserable. . . Finally, Lijunwei and I have a question, Flybird just later looks F, did not make it. . . Unfortunately. . I monsted me to put bug, and then set them, no one was discovered. . Two questions. . . Let's refuel the next time, we still have a chance, Well 16, strive :)

Attachment (PKU1899) 2004.10.10 The correct answer and 3 characters of 8 hours of 8 hours have not found:

Discover your program problem

#include

#include

Using namespace std;

INT I, J;

Bool Findit (int UP1, INT DOWN1, INT LEFT1, INT RIGHT1,

INT UP2, INT DOWN2, INT LEFT2, INT RIGHT2

{

IF (Down2> = DOWN1 && DOWN2 <= UP1 && Left2> = Left1 && Left2 <= Right1) {

Return True;

}

IF (Down2> = DOWN1 && DOWN2 <= UP1 && Right2> = LEFT1 && Right2 <= Right1) {

Return True;

}

IF (Up2> = DOWN1 && UP2 <= UP1 && Left2> = Left1 && Left2 <= Right1) {

Return True;

}

IF (UP2> = DOWN1 && UP2 <= Up1 && Right2> = Left1 && Right2 <= Right1) {

Return True;

}

Return False;

}

#include

Int main (void)

{

// ifstream cin ("test.txt"); int x, y, n; // 1 ~ 1000xy, 0 ~ 100n

INT R [105] [3];

INT O [105] [5]; // The 0th representation of each line is effective

While (CIN >> X >> Y) {

// input

CIN >> N;

IF (n == 0) {

COUT << x * y << "/ n";

CONTINUE;

}

For (i = 1; i <= n; i ) {

CIN >> R [I] [0] >> R [I] [1] >> R [I] [2];

}

//

For (i = 1; i <= n; i ) {

o [i] [0] = 0;

}

// Cal

INT UP1, DOWN1, LEFT1, RIGHT1

For (INT i = 1; i <= n; i ) {

Up1 = r [i] [1] r [i] [2];

DOWN1 = R [I] [1] - R [i] [2];

LEFT1 = R [I] [0] -r [i] [2];

Right1 = r [i] [0] r [i] [2];

// Take a circle to see if it is intersecting, and the intersection will kill the inside.

For (j = 1; j

IF (o [j] [0]! = 0) {// effective, take out judgment

/ / View two rectangles intersect

IF (Findit (O [J], O [J] [2], O [J] [3], O [J] [4],

UP1, DOWN1, LEFT1, RIGHT1)

|| Findit (Up1, Down1, LEFT1, RIGHT1, O [J] [1], O [J] [2], O [J] [3],

o [j]])) {

//merge

IF (O [J] [1]> UP1)

UP1 = O [J] [1];

IF (O [J] [2]

Down1 = O [J] [2];

IF (O [J] [3]

Left1 = O [J] [3];

IF (O [J] [4]> Right1)

Right1 = O [J] [4];

O [J] [0] = 0;

// ******************************************************** *******************************

J = 0; // BUG, ​​after the new rectangle is expanded, you should search from the beginning, it is possible to extend the front. .

// ******************************************************** *******************************

}

}

}

o [i] [0] = 1;

o [i] [1] = UP1;

o [i] [2] = DOWN1;

o [i] [3] = left1;

}

INT all = x * y;

For (i = 1; i <= n; i ) {

IF (o [i] [0]! = 0) {

All = all- (o [i] [1] -O [i] [2]) * (o [i] [4] -o [i] [3]);

}

}

IF (all <0)

ALL = 0;

Cout << all << endl;

}

Return 0;

}

Bamboo

转载请注明原文地址:https://www.9cbs.com/read-108233.html

New Post(0)