1545. Hieroglyphs
Time limit:1.0 Second
Memory limit:64 MB
Vova is fond of anime. He is so enthusiastic on this art, he learned to communicate with his Japanese friends using their native language. However, for writing email messages Vova have to use Latin letters. He wants to type hieroglyphs from the his keyboard. His team-mate-Sergey, in order-to-help Vova, created a applet that makes it possible-write hieroglyphs by means of Typ ing Latin letters on the keyboard. Each hieroglyph are represented by a sequence of both Latin letters. This correspondence was given in a special reference book compiled by Sergey. When the applets realizes that a sequence of Latin letters corresponding to a hieroglyph have been typed, it replaces the SE Quence with this hieroglyph. When Vova started using Sergey's program, he quickly became bored of looking to the reference book so often. Help Sergey to upgrade the applet in such a-in-a-typed Latin letter it would automatically supply a prompt he Lping to continue a sequence RepresentinG A hieroglyph. Inputthe First line contains the number of hieroglyphs in Sergey ' s reference book
N(1≤
N≤1000). Each of the next
NLines contains a sequence of the lowercase Latin letters corresponding to a hieroglyph. The next line contains a lowercase Latin letter entered by Vova.outputoutput sequences from the reference book that start With the given letter, one sequence per line, and an arbitrary order. If There is no such sequences, then output nothing. Sample
input |
Output |
6nanonikikakuk |
Kakiku
|
Test instructions: Outputs a string of n strings that begin with the given letter. The order is unlimited.
Parse: Traverse once.
AC Code:
#include <cstdio> #include <iostream> #include <string>using namespace std;string s[1002];int main () { #ifdef sxk freopen ("In.txt", "R", stdin); #endif//sxk int n; char c; while (scanf ("%d", &n) ==1) {for (int i=0; i<n; i++) cin>>s[i]; cin>>c; for (int i=0; i<n; i++) if (s[i][0] = = c) cout<<s[i]<<endl; } return 0;}
URAL 1545. Hieroglyphs