POJ 2584 T-shirt Gumbo

Source: Internet
Author: User

T-shirt Gumbotime Limit:1000msmemory limit:65536kbthis problem would be judged onPKU. Original id:2584
64-bit integer IO format: %lld Java class name: Main Boudreaux and Thibodeaux is student volunteers for the year's ACM South Central Region ' s programming contest. One of their duties is to distribute the contest T-shirts to arriving teams. The T-shirts had to is ordered in advance using a educated guess as to how many shirts of each size should is needed. Now it falls-Boudreaux and Thibodeaux to determine if-they can hand out T-shirts-all the contestants in a-a-by that M Akes everyone happy.InputInput to this problem would consist of a (Non-empty) series of up to data sets. Each data set is formatted according to the following description, and there would be no blank lines separating data s Ets.

A Single Data set have 4 components:
  1. Start line-a Single line:
    START X

    Where (1 <= X <=) is the number of contestants demanding shirts.
  2. Tolerance line-a single line containing X space-separated pairs of letters indicating the size tolerances of each contes Tant. Valid size Letters is S-small, M-medium, L-large, X-extra large, T-extra extra large. Each letter pair would indicate the range of sizes that would satisfy a particular contestant. The pair would begin with the smallest size the contestant would accept and end with the largest. For example:
    Mx

    Would indicate a contestant that would accept a medium, large, or extra large T-shirt. If a contestant is very-picky, both letters in the pair could be the same.
  3. Inventory line-a Single line:
    S M L X T

    indicating the number of each size shirt in Boudreaux and Thibodeaux ' s inventory. These values would be between 0 and inclusive.
  4. End line-a Single line:
    END

After the last data set, there'll is a single line:
Endofinput

OutputFor each data set, there'll is exactly one line of output. This line would reflect the attitude of the contestants after the T-shirts is distributed. If all the contestants were satisfied, output:

T-shirts rock!

Otherwise, Output:
I ' d rather not wear a shirt anyway ...

Sample Input
START 1st0 0 1 0 0ENDSTART 2SS TT0 0 1 0 0ENDSTART 4SM ML LX XT0 1 1 1 0ENDENDOFINPUT
Sample Output
T-shirts rock! I ' d rather not wear a shirt anyway ... I ' d rather not wear a shirt anyway ...
SourceSouth Central USA 2003 problem solving: multiple matches
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <vector>5 using namespacestd;6 Const intMAXN = -;7 intBound[maxn],shirt[maxn],n;8vector<int>LINK[MAXN];9 BOOLE[MAXN][MAXN],USED[MAXN];Ten BOOLMatchintu) { One      for(inti =1; I <=5; ++i) { A         if(E[u][i] &&!Used[i]) { -Used[i] =true; -             if(Link[i].size () <Bound[i]) { the link[i].push_back (u); -                 return true; -             } -              for(intj = link[i].size ()-1; J >=0; --j) { +                 if(Match (Link[i][j])) { -LINK[I][J] =u; +                     return true; A                 } at             } -         } -     } -     return false; - } - Charans[2][ -] = {"I ' d rather not wear a shirt anyway...\n","T-shirts rock!\n"}; in intMain () { -     Charstr[ -]; toshirt['S'-'A'] =1; +shirt['M'-'A'] =2; -shirt['L'-'A'] =3; theshirt['X'-'A'] =4; *shirt['T'-'A'] =5; $      while((~SCANF ("%s", str)) && strcmp (str,"Endofinput")){Panax Notoginsengscanf"%d",&n); -Memset (E,false,sizeofe); the          for(inti =1; I <= N; ++i) { +scanf"%s", str); A              for(intj = shirt[str[0]-'A']; J <= shirt[str[1]-'A']; ++j) theE[I][J] =true; +         } -          for(inti =1; I <=5; ++i) $scanf"%d", bound +i); $scanf"%s", str); -          for(inti =0; i < MAXN; ++i) link[i].clear (); -         intRET =0; the          for(inti =1; I <= N; ++i) { -memset (Used,false,sizeofused);Wuyi             if(Match (i)) + +ret; the         } -printf"%s", Ans[ret = =n]); Wu     } -     return 0; About}
View Code

POJ 2584 T-shirt Gumbo

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.