Total Submit: 161 Accepted Submit: 37
Have you ever used file searching tools provided by an operating system? For example, in DOS, if you type "dir *.exe", the OS will list all executable files with extension "exe" in the current directory. These days, you are so mad with the crappy operating system you are using and you decide to write an OS of your own. Of course, you want to implement file searching functionality in your OS.
Input:
The input contains several test cases. Consecutive test cases are separated by a blank line.
Each test case begins with an integer N (1 <= N < =100), the number of files in the current directory. Then N lines follow, each line has one string consisting of lowercase letters ('a'..'z') and the dot ('.') only, which is the name of a file. Then there is an integer M (1 <= M <= 20), the number of queries. M lines follow, each has one query string consisting of lowercase letters, the dot and the star ('*') character only. Note that the star character is the "universal matching character" which is used to represent zero or numbers of characters that are uncertain. In the beginning, you just want to write a simple version of file searching, so every string contains no more than 64 characters and there is one and only one star character in the query string.
Process to the End Of File (EOF).
Output:
For each test case, generate one line for the results of each query. Separate file names in the result by a comma (',') and a blank (' ') character. The file names in the result of one query should be listed according to the order they appear in the input. If there is no matching file, output "FILE NOT FOUND" (without the quotation) instead.
Separate two consecutive test cases with a blank line, but Do NOT output an extra blank line after the last one.
Sample Input:4Sample Output:
command.com
msdos.sys
io.sys
config.sys
2
com*.com
*.sys
3
a.txt
b.txt
c.txt
1
*.doc
command.com
msdos.sys, io.sys, config.sys
FILE NOT FOUND
Author: ZHOU, Yuan
Problem Source: Zhejiang University Local Contest 2007
这道题目就是我们决赛时候的一道诡异题目,我和菠菜一起讨论了几种测试用例,但是一直没有发现aaa和aa*aa这个特殊的用例,一直WA至最后一分钟。惨痛啊。回到寝室后把下午写的代码全部扔掉重来,重写代码,并且放弃使用STL
基本思路就是star在中间,左边,右边和仅有一个star的情况分别讨论。代码不是很简洁,老大貌似有更精简的分类,不管了...
#include
#include
using namespace std;
char a[100][100];
#define NOT_FOUND "FILE NOT FOUND\n"
enum CMD {ALL = 1, LEFT, RIGHT, MID};
int main()
{
int n;
bool first = true;
while (scanf("%d", &n) != EOF)
{
if (!first)
printf("\n");
first = false;
int i = 0;
while (i < len =" i;" f =" true;" i =" 0;" size =" strlen(q);" size ="="" cmd =" ALL;" cmd =" LEFT;" i ="=""> 1)
cmd = RIGHT;
else
cmd = MID;
}
}
int star = i;
int j, k;
switch (cmd)
{
case ALL:
for (i = 0; i < f =" false;" i =" 0;" j =" strlen(a[i])" k =" size">= 0 && k > star; --j, --k)
{
if (q[k] != a[i][j])
break;
}
if (k == star)
{
if (!f)
printf(", ");
f = false;
printf("%s", a[i]);
}
}
if (f)
printf(NOT_FOUND);
else
printf("\n");
break;
case RIGHT:
for (i = 0; i < j =" 0," k =" 0;" k ="="" f =" false;" i =" 0;" j =" 0," k =" 0;" tmp =" j;" k ="="" j =" strlen(a[i])" k =" size"> star && j >= tmp; --j, --k)
{
if (q[k] != a[i][j])
break;
}
if (k == star)
{
if (!f)
printf(", ");
f = false;
printf("%s", a[i]);
}
}
}
if (f)
printf(NOT_FOUND);
else
printf("\n");
break;
default:
break;
}
}
}
return 0;
}
28 条评论:
xanax anxiety xanax effects reviews - xanax effects wiki
buy tramadol online tramadol for dogs recommended dosage - tramadol tylenol dosage
buy tramadol online tramadol to buy in usa - generic tramadol hcl 50 mg
buy tramadol online buy tramadol online mastercard - generic tramadol online no prescription
buy carisoprodol soma carisoprodol coupon - carisoprodol 350 mg information
buy tramadol online tramadol y alcohol - tramadol help vicodin withdrawal
buy carisoprodol carisoprodol soma scheduled drug - soma carisoprodol recreational
buy tramadol online buy tramadol in europe - where to buy tramadol online
tramadol online pharmacy tramadol online usa - where can i buy tramadol online
buy cialis online buy cialis 10mg - how to buy cialis online in australia
buy tramadol online tramadol online sale - tramadol janssen
cialis online cialis daily long term side effects - cialis interactions
can you buy cialis online buy cialis usa - cheap cialis ireland
tadalafil tablets cialis heartburn - cialis pro reviews
generic xanax xanax on drug screen test - generic xanax no imprint
buy tramadol online tramadol generic for ultracet - can take 2 tramadol 50mg
buy tramadol generic tramadol online no prescription - tramadol generic for ultracet
buy tramadol online tramadol generic - tramadol ultram same
buy tramadol buy from online texas tramadol - buy tramadol online in florida
learn how to buy tramdadol tramadol medication - tramadol hcl recall
order tramadol no prescription buy discount tramadol - tramadol 50mg wiki
buy tramadol buy tramadol for dogs online - buy tramadol paypal
http://staam.org/#56274 safe place order tramadol online - cheap online tramadol cod
xanax alprazolam xanax drug category - xanax anxiety medication side effects
buy tramadol online does tramadol overdose feel like - tramadol 50mg
buy tramadol without rx cheap tramadol online no prescription - tramadol hcl 50 mg strong
http://bayshorechryslerjeep.com/#2mg xanax 2 mg and alcohol - xanax dosage ocd
xanax 1mg xanax drug family - what is xanax used for depression
发表评论