Codeforces 518B. Tanya and postcard Problem solving report

Source: Internet
Author: User

Title Link: Http://codeforces.com/problemset/problem/518/B

Topic meaning: Given the string s and T, if there is exactly the same letter as s in T, the number equals or more than S, the number of S is added to yay! The answer is less than the number of words in t, and if T has the same letter as s but the case does not correspond (for example, a-a,z-z), it is added to the whoops answer.

It's easy to see, for example. For example S and T are:

Ncmexsslhsuwyemcafatpinzvdeypwjqsnvxlk

The characters S, N, C, M, E, L, S both have, so Ans_yay = 6;xssh x in the string T has a lowercase letter x, the other ssh in the string T is not at all!

In fact........... I did not read the title when doing virtual =! is to look directly at the test data.

If the letter in some position have correct value and correct letter case (in the string s and in the String that Tanya would make), then she shouts joyfully "yay!", and if the the the given position have only the CO Rrect value But it's in the wrong case and then the girl says "whoops".

This sentence is meaningful Ah ~~~~~ to understand the topic is very important drop!

 

1#include <iostream>2#include <cstdio>3#include <cstdlib>4#include <cstring>5#include <algorithm>6 using namespacestd;7 8 Const intMAXN = 2e5 +5;9 Const intMAXL = the;Ten CharS[MAXN], T[MAXN]; One intCs[maxl], CT[MAXL]; A  -InlineintGET_ID (Charch) - { the     if(Ch >='a'&& CH <='Z') -         returnCH-'a'; -     returnch-'A'+ -;//capital letters start from subscript 26 - } + intMain () - { + #ifndef Online_judge AFreopen ("In.txt","R", stdin); at     #endif //Online_judge -  -      while(SCANF ("%s%s", S, t)! =EOF) { -Memset (CS,0,sizeof(CS)); -         intls = strlen (s), lt =strlen (t); -          for(inti =0; i < LS; i++) inCS[GET_ID (S[i])]++; -memset (CT,0,sizeof(CT)); to          for(inti =0; I < lt; i++) +CT[GET_ID (T[i])]++; -  the         intAns_yay =0; *          for(inti =0; i < MAXL; i++) { $             intMinuend =min (cs[i], ct[i]);Panax NotoginsengCs[i]-= minuend, ct[i]-=minuend; -Ans_yay + =minuend; the         } +         intAns_whoops =0; A          for(inti =0; I < -; i++) { the             intAdded = Min (cs[i], ct[i+ -]) + min (cs[i+ -], ct[i]); +Ans_whoops + =added; -         } $printf"%d%d\n", Ans_yay, ans_whoops); $     } -     return 0; -}

Codeforces 518B. Tanya and postcard Problem solving report

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.