青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

coreBugZJ

此 blog 已棄。

Configuration files, ACM-DIY Group Contest 2011 Spring 之 7,HDOJ 3806

Configuration files

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)


Problem Description
In daily project development process, we often use to the configuration file. Now we are going to solve the problem is simple. It is a complete configuration files writing and reading operation and output operation results.
 

Input
The input contains multiple test cases.The first line has one integer N (1 <= N<= 100), represent the number of the test cases.The second line has one integer M (1 <= M <= 2600) ,represent configuration files contain the M line data. The following next M line data represent the content of configuration files. The next line has one integer K (1 <= K <= 10000), represent the number of the operations. Then next K lines follow, each line represent a operation.there are two format in the operations. The first format is “op nodeName variable Name value “ . The second format is “op nodeName variableName”. If op is “U” that represent that it is the Update operation. If op is “G” that represent that it is the Get operation. If op is “I” that represent that it is the Insert operation. The node’s format in the configuration is “[nodeName]”. The format of the value is “variableName=value”. The nodeName, variableName in the configuration files all consist of lowercase character and each of them most contain 100 characters(include 100). The value consist of printable characters and most contain 100 characters(include 100) There may have some whitespaces (space or Tab key) front or behind the nodeName, variableName and value. There may have multiple same variables in the same node in the configuration file and the value of the variable to last shall prevail and the variable names and node name may be the same, in a configuration file won't exist in the same node name, inserting operations if a specified node name designated variables are the already existing failured.
 

Output
For each case, firstly print the “case n:” n represent the number of the case.Then operate according to the output corresponding operation results, to “U” operation if successfully output “update succeed.” otherwise output “update failured.”,to “I” operation if successful ouput “insert succeed.” otherwise ouput “insert failured.” for “G” operation if successful output a specified node specified under the value of the variable, or output “not get the value.”.
 

Sample Input
1
10
[appinfo]
appid = 32152
post = 86,87,89
[userinfo]
name = acmer
password = 2536LR
[softversion]
version =3.0.1
date= 2011-2-20
developers = ACM_DIY
11
U appinfo appid 12345
G appinfo appid
I test value 110alcm
G test value
G userinfo password
G userinf name
I softversion version 3.0.5
G softversion version
U softversion date 2011-2-14
G softversion versio
G softversion Date
 

Sample Output
case 1:
update succeed.
12345
insert succeed.
110alcm
2536LR
not get the value.
insert failured.
3.0.1
update succeed.
not get the value.
not get the value.
 

Author
[FJAU]菜鳥
 

Source
ACM-DIY Group Contest 2011 Spring


Trie 處理插入查找,只是字符串輸入有點繁瑣。。。


  1 #include <stdio.h>
  2 #include <string.h>
  3 #include <ctype.h>
  4 
  5 #define  TC   26
  6 #define  TM   400000
  7 #define  LEN  122
  8 #define  LIM  90000
  9 
 10 int  ibuf;
 11 char buf[ LIM ][ LEN ];
 12 
 13 struct  _Trie
 14 {
 15         char isNode, isValue;
 16         char *pData;
 17         struct  _Trie *ch[ TC ];
 18 };
 19 typedef struct _Trie Trie;
 20 
 21 Trie *root;
 22 
 23 Trie  triemem[ TM ];
 24 int   iTriemem;
 25 
 26 void trie_init() {
 27         root = NULL;
 28         iTriemem = 0;
 29 }
 30 
 31 Trie* trie_new() {
 32         return triemem + iTriemem++;
 33 }
 34 
 35 /* 1 node, 0 other */
 36 int getName( char *str ) {
 37         int isNode = 0;
 38         char ch;
 39         do {
 40                 ch = getchar();
 41         } while ( !( (('a'<=ch)&&(ch<='z')) || (ch=='[') ) );
 42         if ( ch == '[' ) {
 43                 isNode = 1;
 44                 do {
 45                         ch = getchar();
 46                 } while ( (ch<'a'|| ('z'<ch) );
 47         }
 48         while ( ('a'<=ch) && (ch<='z') ) {
 49                 *str++ = ch;
 50                 ch = getchar();
 51         }
 52         *str = 0;
 53         return isNode;
 54 }
 55 
 56 void getValue( char *str ) {
 57         char ch;
 58         do {
 59                 ch = getchar();
 60         } while ( (!isprint( ch )) || (ch=='='|| (ch==' '|| (ch=='\n'|| (ch=='\t') );
 61         while ( isprint( ch ) ) {
 62                 *str++ = ch;
 63                 ch = getchar();
 64         }
 65         *str = 0;
 66 }
 67 
 68 void getCmd( char *str ) {
 69         do {
 70                 *str = getchar();
 71         } while ( ((*str)<'A'|| ('Z'<(*str)) );
 72         str[ 1 ] = 0;
 73 }
 74 
 75 /* insert always,    pData == NULL --- node, else name */
 76 void trie_insert( Trie **pRoot, char *str, char *pData ) {
 77         Trie **= pRoot;
 78         for ( ; ; ) {
 79                 if ( (*p) == NULL ) {
 80                         *= trie_new();
 81                         memset( *p, 0sizeof(Trie) );
 82                 }
 83                 if ( *str ) {
 84                         p = &( (*p)->ch[ (*str) - 'a' ] );
 85                         ++str;
 86                 }
 87                 else {
 88                         if ( pData ) {
 89                                 (*p)->isValue = 1;
 90                                 (*p)->pData = pData;
 91                         }
 92                         else {
 93                                 (*p)->isNode = 1;
 94                         }
 95                         return;
 96                 }
 97         }
 98 }
 99 
100 /* ret 1, succ, other failed ppData == NULL node, else name */
101 int trie_find( Trie *root, char *str, char **ppData ) {
102         Trie *= root;
103         for ( ; ; ) {
104                 if ( p == NULL ) {
105                         return 0;
106                 }
107                 if ( *str ) {
108                         p = p->ch[ (*str) - 'a' ];
109                         ++str;
110                 }
111                 else {
112                         if ( ppData ) {
113                                 *ppData = p->pData;
114                                 return p->isValue;
115                         }
116                         else {
117                                 return p->isNode;
118                         }
119                 }
120         }
121 }
122 
123 int main() {
124         int td, cd = 0, m, k;
125         char cmd[ 10 ], tmp[ LEN ], tmp2[ LEN+LEN ], node[ LEN ], *pData;
126         scanf( "%d"&td );
127         while ( td-- > 0 ) {
128                 printf( "case %d:\n"++cd );
129                 ibuf = 0;
130                 trie_init();
131                 scanf( "%d"&m );
132                 while ( m-- > 0 ) {
133                         if ( getName( tmp ) ) {
134                                 trie_insert( &root, tmp, NULL );
135                                 strcpy( node, tmp );
136                         }
137                         else {
138                                 getValue( buf[ ibuf++ ] );
139                                 strcpy( tmp2, node );
140                                 strcat( tmp2, tmp );
141                                 trie_insert( &root, tmp2, buf[ ibuf-1 ] );
142                         }
143                 }
144                 scanf( "%d"&k );
145                 while ( k-- > 0 ) {
146                         getCmd( cmd );
147                         switch ( cmd[ 0 ] ) {
148                         case 'U' :
149                                 getName( node );
150                                 strcpy( tmp2, node );
151                                 getName( tmp );
152                                 strcat( tmp2, tmp );
153                                 getValue( buf[ ibuf++ ] );
154                                 if ( trie_find( root, node, NULL ) && trie_find( root, tmp2, &pData ) ) {
155                                         trie_insert( &root, tmp2, buf[ ibuf-1 ] );
156                                         puts( "update succeed." );
157                                 }
158                                 else {
159                                         puts( "update failured." );
160                                 }
161                                 break;
162                         case 'G' : 
163                                 getName( node );
164                                 strcpy( tmp2, node );
165                                 getName( tmp );
166                                 strcat( tmp2, tmp );
167                                 if ( trie_find( root, node, NULL ) && trie_find( root, tmp2, &pData ) ) {
168                                         puts( pData );
169                                 }
170                                 else {
171                                         puts( "not get the value." );
172                                 }
173                                 break;
174                         case 'I' : 
175                                 getName( node );
176                                 strcpy( tmp2, node );
177                                 getName( tmp );
178                                 strcat( tmp2, tmp );
179                                 getValue( buf[ ibuf++ ] );
180                                 if ( trie_find( root, node, NULL ) && trie_find( root, tmp2, &pData ) ) {
181                                         puts( "insert failured." );
182                                 }
183                                 else {
184                                         trie_insert( &root, node, NULL );
185                                         trie_insert( &root, tmp2, buf[ ibuf-1 ] );
186                                         puts( "insert succeed." );
187                                 }
188                                 break;
189                         }
190                 }
191         }
192         return 0;
193 }
194 


posted on 2011-03-27 21:08 coreBugZJ 閱讀(1017) 評論(0)  編輯 收藏 引用 所屬分類: ACM

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            免费在线国产精品| 性久久久久久久久久久久| 久久综合色影院| 欧美电影在线观看| 91久久在线播放| 伊人男人综合视频网| 影音先锋日韩精品| 欧美激情 亚洲a∨综合| 亚洲一区二区三区在线视频| 欧美一级淫片播放口| 欧美刺激午夜性久久久久久久| 国产精品免费在线| 在线观看91精品国产入口| 欧美国产视频日韩| 欧美日韩精品免费看 | 一本久久a久久免费精品不卡| 午夜性色一区二区三区免费视频 | 欧美大片在线观看一区| 一区二区三区欧美亚洲| 久久免费黄色| 亚洲精品日韩一| 久久精品视频免费| 国产精品家教| 日韩亚洲欧美在线观看| 久久久久久久91| 亚洲一区黄色| 亚洲精品国产精品国产自| 久久久久一本一区二区青青蜜月| 免费精品视频| 久久gogo国模啪啪人体图| 一区二区动漫| 曰本成人黄色| 亚洲女性裸体视频| 国产精品美女久久久久久免费| 久久尤物视频| 久久综合电影一区| 今天的高清视频免费播放成人| 午夜一区二区三区在线观看| 一区二区国产在线观看| 亚洲春色另类小说| 欧美成人精品在线观看| 久久国产视频网站| 韩日精品视频| 欧美二区在线| 国产一区二区三区四区三区四| 久久狠狠婷婷| 久久精品亚洲精品| 午夜精品久久久久久久久久久 | 久色成人在线| 国产农村妇女精品| 久久精品视频免费播放| 国产精品草草| 香蕉视频成人在线观看| 欧美色道久久88综合亚洲精品| 亚洲综合99| 欧美一区二区三区免费观看视频| 亚洲深夜激情| 西瓜成人精品人成网站| 亚洲一区二区三区高清| 亚洲欧美中文日韩在线| 永久免费精品影视网站| 久久狠狠久久综合桃花| 久久精品亚洲一区二区三区浴池| 国产精品久久久久久久久久久久久久| 亚洲国产一区二区三区a毛片| 欧美顶级艳妇交换群宴| 欧美不卡在线视频| 91久久午夜| 亚洲一区二区三区在线| 亚洲欧美经典视频| 久久综合影音| 欧美黄在线观看| 艳女tv在线观看国产一区| 欧美一区二区三区四区视频| 久久久久国产精品人| 国内综合精品午夜久久资源| 久久精品女人天堂| 美女成人午夜| 欧美日韩中文| 亚洲综合不卡| 久久久午夜视频| 亚洲国产日韩欧美| 午夜精品免费视频| 久久综合激情| 亚洲九九爱视频| 久久久精品一区二区三区| 欧美sm极限捆绑bd| av不卡在线| 国产麻豆9l精品三级站| 亚洲黄色一区二区三区| 亚洲在线视频观看| 国产一区二区中文字幕免费看| av成人福利| 日韩亚洲视频| 国产日韩欧美高清| 一区二区免费在线观看| 欧美在线影院在线视频| 在线成人激情| 国产精品国产三级国产专区53 | 国产亚洲精品久久久久久| 美女露胸一区二区三区| 免费在线看成人av| 亚洲色无码播放| 黄色av日韩| 欧美日韩国产在线播放| 性欧美精品高清| 亚洲精品一区二区三区99| 久久免费黄色| 亚洲在线视频网站| 亚洲精品久久久一区二区三区| 国产欧美日韩另类视频免费观看| 男男成人高潮片免费网站| 亚洲欧美日韩成人高清在线一区| 欧美大片免费| 久久裸体艺术| 性色av一区二区三区红粉影视| 亚洲精品社区| 亚洲国产一区二区a毛片| 国产亚洲aⅴaaaaaa毛片| 欧美日韩视频在线一区二区观看视频| 亚洲风情亚aⅴ在线发布| 亚洲另类在线一区| 好吊一区二区三区| 国产欧美日韩中文字幕在线| 欧美日韩视频第一区| 欧美成人一区在线| 性欧美xxxx大乳国产app| 中日韩美女免费视频网址在线观看| 亚洲一区免费观看| 99亚洲精品| 亚洲欧洲在线视频| 亚洲国产精品久久久| 欧美国产先锋| 这里只有精品视频| 亚洲精品乱码视频| 午夜精品久久久久久久蜜桃app| 亚洲免费av电影| 亚洲破处大片| 在线观看欧美日韩国产| 黄色成人在线| 在线观看视频一区二区欧美日韩| 激情久久综艺| 亚洲高清在线| 日韩视频一区二区三区在线播放免费观看| 精品成人一区二区三区| 极品尤物久久久av免费看| 精品91视频| 亚洲黄色精品| 日韩午夜电影| 亚洲图片欧美日产| 亚洲一区一卡| 久久国产精品久久w女人spa| 久久精品一区二区三区四区| 久久青草欧美一区二区三区| 久久亚洲综合| 亚洲国产成人午夜在线一区| 亚洲精品美女久久7777777| 亚洲毛片网站| 亚洲一区二区在| 午夜精品久久久久久久蜜桃app| 午夜久久久久久| 久久综合给合| 欧美日韩另类国产亚洲欧美一级| 国产精品久久久久久久浪潮网站| 国产精品中文在线| 在线精品观看| 中日韩男男gay无套| 久久成人精品无人区| 久久综合网络一区二区| 91久久精品国产91久久性色| 一区电影在线观看| 久久久久久久久久看片| 小黄鸭精品aⅴ导航网站入口| 久久久久免费观看| 欧美日韩国产免费观看| 国产欧美一区二区精品婷婷| 亚洲第一页在线| 亚洲一区二区av电影| 另类天堂av| 亚洲性视频h| 亚洲欧美国产精品桃花| 麻豆成人综合网| 国产精品另类一区| 亚洲日本电影| 久久精品国产欧美亚洲人人爽| 亚洲国产日韩欧美综合久久| 午夜精品久久久99热福利| 欧美激情综合五月色丁香| 免费观看一区| 国产欧美欧洲在线观看| 日韩视频在线播放| 久久久久国产精品一区三寸| 亚洲毛片在线免费观看| 久久青草久久| 女同性一区二区三区人了人一| 国产伦精品一区| 一本到12不卡视频在线dvd| 美日韩精品免费观看视频| 亚洲一区激情| 欧美视频在线观看|