1854:refrigerator Magnets
Submit Page Summary Time Limit: 2 Sec Memory Limit: submitted Mb: Solved: >
Description
Like many families with small children, my family ' s refrigerator are adorned with a set of alphabet magnets:26 separate MA Gnets, each containing one letter of the alphabet. These magnets can is rearranged to create words and phrases. I feel it's my parental duty to use these magnets to create messages that's witty and insightful, yet at the same time Caring and supportive. Unfortunately, I am somewhat hindered in the "this" task by the fact that I can have only make phrases the use of each letter once.
For example, a nice inspiring message to leave for the children might is, "I love you." Unfortunately, I cannot make this message using my magnets because it requires the "O" s. I can, however, make the message, "I love MUSTARD." Admittedly this message is ' t ' as meaningful, but it does manage the use of any letters more than once.
You is to write a program that would look at a list of possible phrases and which phrases can be written using REFR Igerator Magnets.
Input
The input would consist of one or more lines, ending with a line that contains only the word "END". Each line would be characters or less, and would consist of one or more words separated to a single space each, with Word s using only uppercase letters (A–Z). There'll is not being any leading or trailing whitespace, and there'll is not the any blank lines.
Output
Output only the lines which can being written in refrigerator magnets-that are, the lines which has no duplicate letters. Output them exactly the same as they were in the input-white spaces and all. Do not output the final "END" string.
Sample Input
I love YouI Love Mustardhappy birthdayglad U bornsmileimaginewhats up dochave A Nice dayend
Sample Output
I Love Mustardglad U bornsmilewhats up DOC
Hintsource
Mid-Central USA Regional Contest
http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1854
The end of the question should be the first three characters end, not the entire string is end, there is extra output
Then a lot of people died in the pit ....
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include < queue> #include <vector> #include <iomanip> #include <math.h> #include <map>using namespace STD; #define FIN freopen ("Input.txt", "R", stdin), #define FOUT freopen ("Output.txt", "w", stdout); #define INF 0x3f3f 3f3f#define infll 0x3f3f3f3f3f3f3f#define Lson l,m,rt<<1#define rson m+1,r,rt<<1|1typedef Long Long LL ; typedef pair<int, int> pii;int main () {char s[105]; int num[105]; while (1) {gets (s); if (s[0] = = ' E ' && s[1] = = ' N ' && s[2] = = ' D ') break; int flag = 0; memset (num, 0, sizeof (num)); int len = strlen (s); for (int i = 0; i < len; i++) {if (s[i] = = ") continue; Num[s[i]-' A ']++; } for (int i = 0; i <; i++) {if (Num[i] >= 2) flag = 1; } if (flag) continue; else puts (s); } return 0;}
Csuoj 1854 Refrigerator Magnets