首页 > ACM题库 > HDU-杭电 > HDU 3321-Rose Shop-待解决[解题报告]HOJ
2014
03-16

HDU 3321-Rose Shop-待解决[解题报告]HOJ

Rose Shop

问题描述 :

Small JH,the boss of the rose shop, preparated many roses for the valentine’s day.It’s too much people come and buy roses,so Small JH have to put the roses back in every t(0 < t) minutes.The roses put as a thwartwise tower in the rail (look at the picture).You can get the number of rose with n(0<n<13) rows is n*(n + 1)/ 2.
a bundle of rose like this:

    @
  @~@~@
@~@\@/@~@
\@|@|@|@/
 \\\|///
  \\|//
   \|/
   =&=
   /|\

This is the rose in the rail:

openGL

The rose numbered as below:

      1
    2   3
  4   5   6
7   8   9  10

The rule of putting the rose in is to find a empty bay where the number is smallest and put the rose in.We can suppose he add the rose spend no time,the customer should wait after Small JH add the rose.
The shop opened at 8:00am and closed at 11:00pm(the customer can buy rose at 11:00pm but the boss will not add the rose at 11:00pm).He want to know the situation of the customer buy the rose and the placement of rose after 11:00pm.If the customer see the shop is closed,he will leave.

输入:

The input will consist of several cases, please deal with till the end of file. Each case contains three integers N , T and M (0<N<13, 0<T, 0<M<=100) representing there are N rows of roses,small JH add the rose every T minutes and M customer.Then follow M*2 lines as below format:
hh:mm k
a1 a2…ak
stand for at hh:mm the customer want to buy k roses,ai means he wants the rose numberd ai.at the same time,only one customer into the shop.
the time is increase and 0 < k <= n*(n + 1)/ 2, 0 < ai <= n*(n+1)/2.

输出:

The input will consist of several cases, please deal with till the end of file. Each case contains three integers N , T and M (0<N<13, 0<T, 0<M<=100) representing there are N rows of roses,small JH add the rose every T minutes and M customer.Then follow M*2 lines as below format:
hh:mm k
a1 a2…ak
stand for at hh:mm the customer want to buy k roses,ai means he wants the rose numberd ai.at the same time,only one customer into the shop.
the time is increase and 0 < k <= n*(n + 1)/ 2, 0 < ai <= n*(n+1)/2.

样例输入:

2 1 1
8:00 1
2
2 10000 1
8:00 1
2

样例输出:

You bought 1 beams of rose
+---------------------+
|          @          |
|        @~@~@        |
|      @~@\@/@~@      |
|    @ \@|@|@|@/ @    |
|  @~@~@\\\|///@~@~@  |
|@~@\@/@~@\|/@~@\@/@~@|
|\@|@|@|@/\|/\@|@|@|@/|
| \\\|/// =&= \\\|/// |
|  \\|//  /|\  \\|//  |
|   \|/         \|/   |
|   =&=         =&=   |
|   /|\         /|\   |
+---------------------+
You bought 1 beams of rose
+---------------------+
|          @          |
|        @~@~@        |
|      @~@\@/@~@      |
|      \@|@|@|@/ @    |
|       \\\|///@~@~@  |
|        \\|/@~@\@/@~@|
|         \|/\@|@|@|@/|
|         =&= \\\|/// |
|         /|\  \\|//  |
|               \|/   |
|               =&=   |
|               /|\   |
+---------------------+


  1. bottes vernies blanches

    I appreciate the efforts you men and women place in to share blogs on such sort of matters, it was certainly useful. Keep Posting!

  2. 一开始就规定不相邻节点颜色相同,可能得不到最优解。我想个类似的算法,也不确定是否总能得到最优解:先着一个点,随机挑一个相邻点,着第二色,继续随机选一个点,但必须至少有一个边和已着点相邻,着上不同色,当然尽量不增加新色,直到完成。我还找不到反例验证他的错误。。希望LZ也帮想想, 有想法欢迎来邮件。谢谢