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

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 處理插入查找,只是字符串輸入有點(diǎn)繁瑣。。。


  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) 評(píng)論(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>
            欧美成ee人免费视频| 一区二区日韩欧美| 一本一本久久| 91久久精品网| 亚洲国产日韩一级| 亚洲日本va午夜在线电影| 性做久久久久久久久| 亚洲一区二区三区乱码aⅴ蜜桃女| 欧美激情日韩| 99在线精品视频| 亚洲女性喷水在线观看一区| 午夜精品久久久久久| 久久精品在线视频| 免费欧美电影| 国产精品激情电影| 在线观看视频欧美| 亚洲视频axxx| 久久蜜桃av一区精品变态类天堂| 老色鬼精品视频在线观看播放| 欧美黄免费看| 国产精品99久久不卡二区| 久久精品最新地址| 欧美日韩成人在线观看| 国产老肥熟一区二区三区| 影音先锋在线一区| 亚洲一区二区视频| 美脚丝袜一区二区三区在线观看| 亚洲精品视频啊美女在线直播| 亚洲欧美日本在线| 欧美欧美全黄| 在线免费观看欧美| 亚洲综合国产| 欧美激情久久久| 亚洲午夜影视影院在线观看| 老司机精品视频一区二区三区| 国产精品久久久久久久久免费桃花 | 亚洲一区二区视频在线| 亚洲欧美在线免费| 亚洲电影在线播放| 亚洲欧美成人在线| 欧美绝品在线观看成人午夜影视 | 一区二区免费看| 久久国产黑丝| 国产精品亚洲а∨天堂免在线| 亚洲精品美女久久7777777| 欧美在线在线| 一区二区三区四区五区精品| 免费视频久久| 黄色小说综合网站| 久久精品亚洲一区二区| 夜夜精品视频一区二区| 欧美激情精品久久久久久蜜臀| 激情成人亚洲| 久久一二三区| 久久久成人网| 激情视频一区| 久久综合导航| 久久久成人网| 一区二区三区在线高清| 久久久五月婷婷| 久久综合久色欧美综合狠狠| 亚洲五月婷婷| 国产精品天天看| 亚洲永久免费精品| 在线亚洲免费视频| 国产精品免费观看在线| 亚洲一区二区三区精品在线| 亚洲欧洲三级| 91久久久在线| 欧美日韩一二区| 最新中文字幕一区二区三区| 国产精品永久免费视频| 亚洲影视在线| 亚洲一二三区精品| 国产精品久久久久久影视| 亚洲视频综合| 亚洲欧美成人网| 国产一区二区在线观看免费播放| 亚洲欧美综合| 欧美亚洲在线观看| 国产专区综合网| 欧美成人a视频| 欧美精品在线观看91| 在线性视频日韩欧美| 亚洲一区www| 国产综合一区二区| 亚洲国产精品精华液2区45| 欧美巨乳在线观看| 欧美一二区视频| 久久久999国产| 亚洲乱码精品一二三四区日韩在线| 亚洲激情影院| 国产日韩欧美日韩| 欧美国产一区二区三区激情无套| 欧美成人精品h版在线观看| 一本色道久久综合亚洲精品高清| 亚洲男女自偷自拍| 亚洲国产婷婷香蕉久久久久久| 日韩视频不卡| 激情综合中文娱乐网| 亚洲三级性片| 国语自产精品视频在线看抢先版结局 | 欧美三区美女| 久久国产综合精品| 老司机精品久久| 亚洲自拍高清| 美女久久网站| 久久精品免费电影| 欧美连裤袜在线视频| 久久久久久**毛片大全| 欧美日韩视频在线第一区| 久久人人爽爽爽人久久久| 欧美日韩精品免费观看视频完整| 久久精品国产第一区二区三区最新章节 | 91久久午夜| 国产视频一区二区三区在线观看| 国产精品乱码一区二区三区| 美女诱惑黄网站一区| 国产精品午夜春色av| 亚洲日本中文字幕区| 狠狠狠色丁香婷婷综合激情| 中文在线一区| 一区二区三区欧美在线| 免费成人高清在线视频| 老司机午夜精品视频在线观看| 欧美日韩专区| 亚洲欧洲在线看| 亚洲日本中文字幕免费在线不卡| 久久爱www| 久久久www| 国产日韩在线看片| 亚洲综合视频网| 亚洲自拍都市欧美小说| 欧美日韩性生活视频| 亚洲精品日日夜夜| 亚洲美女在线国产| 欧美精品麻豆| 99re热精品| 亚洲图片在区色| 欧美日一区二区在线观看| 亚洲精选一区二区| 一本久道久久综合中文字幕| 欧美精品一区二区精品网| 亚洲激情电影在线| 日韩视频一区二区三区在线播放免费观看 | 欧美在线日韩在线| 欧美色视频在线| 一本综合精品| 亚洲欧美影院| 国产亚洲欧美另类中文| 欧美中文字幕不卡| 久久精品视频网| 在线免费不卡视频| 免费欧美在线视频| 亚洲片国产一区一级在线观看| 99在线精品视频在线观看| 欧美日韩一区二区三区| 国产精品99久久久久久久女警| 香蕉成人伊视频在线观看 | 国产精品99久久99久久久二8 | 亚洲国内在线| 亚洲欧美日韩国产精品| 国产欧美在线看| 久久中文字幕一区| 最新日韩av| 久久精品国产一区二区三区免费看| 国内精品视频在线观看| 亚洲精品国产精品国自产在线 | 欧美四级电影网站| 欧美亚洲视频一区二区| 女同性一区二区三区人了人一| 亚洲啪啪91| 欧美三级欧美一级| 欧美一二区视频| 亚洲人成在线观看一区二区| 亚洲制服av| 精品69视频一区二区三区| 欧美激情视频给我| 午夜精品剧场| 亚洲精品美女在线观看| 久久久精彩视频| 一本久久a久久免费精品不卡| 国产日本欧美一区二区三区在线| 免费欧美电影| 久久福利资源站| 99视频有精品| 美乳少妇欧美精品| 午夜一级在线看亚洲| 亚洲国产99| 国产一区二区三区av电影| 欧美日韩免费在线| 久久久久久久一区二区三区| 宅男精品视频| 亚洲精品之草原avav久久| 老鸭窝91久久精品色噜噜导演| 亚洲一区二区三区在线观看视频| 亚洲成人在线免费| 国产视频亚洲| 国产精品一区二区久久国产| 欧美精品一区二区精品网|