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

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 閱讀(1033) 評論(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>
            在线亚洲国产精品网站| 99综合视频| 国产精品视频男人的天堂| 欧美国产激情二区三区| 国产亚洲一区精品| 一区二区激情视频| 亚洲人成久久| 久久亚洲综合色| 久久综合免费视频影院| 国产日韩欧美精品在线| 亚洲色图自拍| 宅男噜噜噜66国产日韩在线观看| 毛片av中文字幕一区二区| 久久本道综合色狠狠五月| 国产精品成人aaaaa网站| 亚洲黄一区二区三区| 狠狠色狠狠色综合系列| 欧美在线一区二区| 久久精品国产久精国产思思 | 这里只有精品丝袜| 亚洲精品美女久久久久| 免费一区二区三区| 亚洲国产成人不卡| 91久久国产精品91久久性色| 久久久亚洲午夜电影| 麻豆成人精品| 亚洲欧洲三级电影| 欧美片第一页| 99v久久综合狠狠综合久久| 一区二区三区av| 欧美日韩专区在线| 亚洲美女一区| 亚洲欧美日韩国产综合在线| 国产精品理论片| 亚洲欧美日韩精品久久奇米色影视| 午夜亚洲性色视频| 国产一区二区三区不卡在线观看| 欧美一级播放| 欧美r片在线| 亚洲日本视频| 欧美四级电影网站| 亚洲免费一在线| 老司机精品久久| 91久久国产综合久久蜜月精品| 你懂的亚洲视频| 一区二区黄色| 久久精品日韩欧美| 亚洲国产色一区| 欧美日韩欧美一区二区| 亚洲女优在线| 男女激情久久| 亚洲视屏在线播放| 国产亚洲一级高清| 欧美国产精品日韩| 亚洲一区二区精品视频| 久久久久久伊人| 亚洲美女精品一区| 国产精品亚洲综合一区在线观看| 久久久久九九视频| 99v久久综合狠狠综合久久| 久久国产一区二区| 99综合精品| 国产在线一区二区三区四区 | 久热精品视频在线观看一区| 亚洲精品欧美一区二区三区| 国产精品高潮呻吟视频 | 午夜激情一区| 亚洲国产国产亚洲一二三| 亚洲欧美春色| 91久久综合亚洲鲁鲁五月天| 国产伦精品一区二区三区免费迷 | 亚洲日本va午夜在线影院| 国产精品国产馆在线真实露脸| 久久精品国产免费看久久精品| 亚洲精品欧美专区| 欧美11—12娇小xxxx| 亚洲欧美日韩一区二区三区在线观看| 伊人激情综合| 国产乱码精品一区二区三| 欧美freesex交免费视频| 午夜亚洲性色福利视频| 日韩视频精品在线观看| 免费中文日韩| 久久久蜜桃一区二区人| 亚洲综合日本| 一区二区三区四区国产| 亚洲高清免费视频| 国内精品美女av在线播放| 国产精品成人v| 欧美日韩一区二区视频在线| 欧美成人国产| 久久综合一区二区| 久久精视频免费在线久久完整在线看 | 性欧美xxxx视频在线观看| 亚洲久色影视| 亚洲激情影视| 在线播放中文一区| 国产亚洲第一区| 国产乱码精品一区二区三| 国产精品夫妻自拍| 国产精品观看| 国产精品免费网站| 欧美日韩天堂| 欧美日精品一区视频| 欧美日韩第一区日日骚| 欧美日本三级| 欧美日韩精品一二三区| 欧美精品一区二区三区在线播放| 欧美高潮视频| 欧美精品一区二| 欧美日韩情趣电影| 欧美日韩亚洲天堂| 欧美视频在线视频| 欧美性猛片xxxx免费看久爱| 欧美日韩亚洲91| 欧美午夜精品久久久久久浪潮| 欧美日韩一区三区| 国产精品免费看| 国产偷久久久精品专区| 国产一区二区三区久久悠悠色av| 狠狠色狠色综合曰曰| 亚洲黄色视屏| 亚洲视频精品在线| 欧美亚洲日本网站| 久久九九久精品国产免费直播| 久久久久久久久久久久久女国产乱 | 欧美在线视频日韩| 久久久久久久综合色一本| 久久综合中文色婷婷| 欧美黄色一区| 99精品欧美一区二区蜜桃免费| 中文成人激情娱乐网| 欧美亚洲免费高清在线观看| 久久久水蜜桃av免费网站| 欧美+亚洲+精品+三区| 欧美日韩免费观看一区三区| 国产精品影视天天线| 伊人久久久大香线蕉综合直播| 亚洲日本欧美日韩高观看| 亚洲主播在线观看| 免费观看欧美在线视频的网站| 亚洲欧洲一区| 性娇小13――14欧美| 欧美国产大片| 国产欧美一区二区色老头| 亚洲国产精品久久91精品| 亚洲香蕉伊综合在人在线视看| 久久蜜桃av一区精品变态类天堂| 亚洲黄色天堂| 亚洲欧美成人综合| 欧美mv日韩mv国产网站| 国产欧美精品一区二区三区介绍| 亚洲国产精品久久人人爱蜜臀| 亚洲一区高清| 免费看成人av| 亚洲欧美www| 欧美日韩极品在线观看一区| 激情av一区| 午夜综合激情| 91久久线看在观草草青青| 欧美一级网站| 国产精品sm| 亚洲老司机av| 免费成人激情视频| 欧美一二三区在线观看| 欧美午夜女人视频在线| 亚洲精品日产精品乱码不卡| 久久影视精品| 校园春色国产精品| 国产精品高清一区二区三区| 亚洲日本黄色| 免费成人激情视频| 久久激情婷婷| 国产午夜精品久久久| 亚洲免费婷婷| 日韩亚洲欧美精品| 欧美国产免费| 亚洲人午夜精品免费| 欧美寡妇偷汉性猛交| 久久久国产91| 精品91久久久久| 久久久夜色精品亚洲| 香蕉av福利精品导航| 国产美女精品一区二区三区| 亚洲女人天堂av| 国产精品99久久99久久久二8| 欧美日韩高清在线播放| 91久久久在线| 欧美激情四色| 欧美成人国产一区二区| 亚洲欧洲精品一区二区三区不卡 | 午夜视频久久久| 国产精品一区二区三区成人| 亚洲一区二区网站| 亚洲天堂黄色| 国产精品每日更新| 欧美一区二区三区在线播放| 亚洲一区精品视频| 国产亚洲激情视频在线| 久久精品男女|