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