回分類題庫
d197: CP Lab Exercise: BBS Bitwise
出處:

Difficulity : N/A
Accepted : 26 Times | Submit :70 Times | Clicks : 1235
Accepted : 23 Users | Submit : 25 Users | Accepted rate : 92%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2010-12-15 15:49

Content :

A BBS System has a lot of users. As a admin of the station, we need to search those who has special permissions to secure the system.

You are asked to write a simple program to get the user data and do some simple search.

For the second exercise, we practice using bitwise operation and we base on our previous work on exercise 1.

You can base on the following code   ~g9803/bbs_bitwise_ex.c
 

Input :

There are couple sets of data.
For each set of data, The first line is an integer n, indicates that n users to be entered. (0 <= n <= 50)
The following n lines are the user data, each line is compose of two strings "id" and "permissions" (length == 8)
Permissions is composed of "+" or "-", indicates who has / has no that permission.
The sequence is same to the query string below.
After entering the user data, there are some lines of queries. Each queries is a string, 0 means the search is over.
The query is one of these:
"Valid", "BMW", "Post", "Mail", "Denied", "BM", "Cloak", "Admin"

Output :

For each queries, if there is any user has that permission then output a line with the syntax "s1 s2", which s1 is the user id and s2 is the permissions(unsigned int).

If there is more than one users has the permissions, output all of them according to the input order.

Sample Input :

5
GW ++++++++
Sheldon -+-+-+-+
Leonerd -------+
pandia ++------
Raj --+-----
Post
BMW
Admin
0
3
GW ++++++++
ku ---+----
pandia --------
Post
BMW
Admin
0

Sample Output :

GW 255
Raj 4
GW 255
Sheldon 170
pandia 3
GW 255
Sheldon 170
Leonerd 128
GW 255
GW 255
GW 255

Hint :


  

Author :


  Solve it!   Status Forum (0)

C++
C
JAVA
沒有解題記錄 28244. admin (2 ms , 218KB)
34229. king_of_laba (4 ms , 212KB)
30708. nothinglo (4 ms , 230KB)
28446. cp99703008 (4 ms , 226KB)
28267. cp99703028 (4 ms , 218KB)
55105. nwgs524513cja (124 ms , 174KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡