POJ1083-Moving tables

Source: Internet
Author: User

Reprinted please indicate the source: Thank youHttp://user.qzone.qq.com/289065406/blog/1299062100

Tip: use the room number to separate the corridor. A counter is set for each "sub-corridor". Each time a + 1 is passed, the counter is sorted quickly. The maximum number of times x10 is the answer.

This question is a bit greedy at first, because it may be very stupid and inefficient to calculate the intersection point (critical point) of the input moving range, in addition, we need to consider a bunch of possible situations. I have done this using the stack in this way and listed all possible examples. The results are consistent but there is no limit to wa .... So let the public: Do not go astray...

 

 

// Memory time // 232 K 0 Ms # include <iostream> # include <algorithm> using namespace STD; int main (void) {int room [401]; int test, move_time, I, j, temp; int from [200], to [200]; CIN> test; For (j = 0; j <test; j ++) {memset (room, 0, sizeof (room); // note that initialization is required for each test, instead of initializing CIN> move_time; for (I = 0; I <move_time; I ++) {CIN> from [I]> to [I]; If (from [I]> to [I]) {temp = from [I]; from [I] = to [I]; To [I] = temp;} If (from [I] % 2! = 0) from [I] ++; If (to [I] % 2! = 0) to [I] ++; For (temp = from [I]; temp <= to [I]; temp + = 2) {room [temp] ++ ;}} sort (room, room + 401); cout <room [400] x 10 <Endl ;}return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.