Srm480 div1 250 points

Source: Internet
Author: User

Okay, I admit that this question is very simple (it won't be ignored by STL children). If I read the wrong question, it will lead to success... Speechless...

 

Today's 250 is not very difficult. The main points are:

1. For string cutting, the handwritten cut function is relatively safe. Of course, the STL string stream can be directly cut by space.

2. Search for keywords. Well, here is a good technique. Use the red/black tree (SET) to maintain all the dangerous keywords.

3. The judgment condition is that the dangerous website is only used when the dangerous keywords exceed the specified value. Otherwise, no.

4. When a website is a dangerous website, all its keywords are dangerous. At this time, we need to add all the keywords to the red/black tree for management.

5. For the reason of 4, to scan n times (similar to the bellmanford algorithm), the order of addition is not the original order. Here, the ID is sorted at the end,

You can use a ing map to store subscript.

 

 

My code (core part ):

Set <string> st; <br/> Map <string, int> ID; <br/> bool use [60]; </P> <p> bool comp (const string & A, const string & B) <br/>{< br/> return ID [a] <ID [B]; <br/>}</P> <p> bool check (const string & Key, int num) <br/>{< br/> int Len = key. length (); <br/> string ret; <br/> vector <string> V; <br/> int CNT = 0, size = 0; </P> <p> for (INT I = 0; I <Len; I ++) <br/> {<br/> ret = ""; <br/> while (I <Len & Key [I]! = '') <Br/>{< br/> RET + = Key [I]; <br/> I ++; <br/>}< br/> v. push_back (RET); <br/>}< br/> size = v. size (); </P> <p> for (INT I = 0; I <size; I ++) <br/> If (St. find (V [I])! = ST. end () <br/>{< br/> CNT ++; <br/>}</P> <p> If (CNT> = num) <br/> {<br/> for (INT I = 0; I <size; I ++) <br/> St. insert (V [I]); <br/> return true; <br/>}< br/> else <br/> return false; <br/>}</P> <p> class internetsecurity <br/>{< br/> public: <br/> vector <string> determinewebsite (vector <string> Add, vector <string> key, vector <string> Dang, int num) <br/>{< br/> int n = add. size (); <br/> vector <string> V; </P> <p> memset (Use, 0, sizeof (use); <br/> ID. clear (); <br/> St. clear (); <br/> for (INT I = 0; I <n; I ++) <br/> ID [add [I] = I; <br/> int size = Dang. size (); <br/> for (INT I = 0; I <size; I ++) <br/> St. insert (Dang [I]); </P> <p> for (int K = 0; k <n; k ++) <br/> for (INT I = 0; I <n; I ++) <br/> If (! Use [I] & check (Key [I], num) <br/>{< br/> use [I] = true; <br/> v. push_back (add [I]); <br/>}</P> <p> sort (v. begin (), V. end (), comp); <br/> return V; <br/>}< br/> };

 

Conclusion: Reading questions carefully should not be difficult to understand. It is a bad phenomenon to hate reading questions recently.

 

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.