我希望你是我独家记忆

一段永远封存的记忆,随风而去
posts - 263, comments - 31, trackbacks - 0, articles - 3
   :: 首页 :: 新随笔 ::  :: 聚合  :: 管理

URAL1644

Posted on 2008-10-26 14:21 Hero 阅读(138) 评论(0)  编辑 收藏 引用 所属分类: 代码如诗--ACM
 1 // 1644 C++ Accepted 0.015 125 KB URAL
 2 
 3 #include <stdio.h>
 4 #include <stdlib.h>
 5 #include <string.h>
 6 
 7 const int size = 110 ;
 8 
 9 struct NODE {
10     int num ;
11     int isok ;
12 };
13 struct NODE node[size] ;
14 
15 int inn ; char instr[50] ;
16 
17 int cmp( const void *a, const void *b )
18 {
19     struct NODE *= (struct NODE *)a ;
20     struct NODE *= (struct NODE *)b ;
21 
22     if( c->num != d->num ) return c->num - d->num ;
23     else return d->isok - c->isok ;//注意这里要反着来,可能有num相同的情况
24 }
25 
26 int main()
27 {
28     while( scanf( "%d"&inn ) != EOF )
29     {
30         forint i=1; i<=inn; i++ )
31         {
32             scanf( "%d"&node[i].num ) ;
33             scanf( "%s", instr ) ;
34             if0 == strcmp( "satisfied", instr ) ) node[i].isok = 1 ;
35             else node[i].isok = 0 ;
36         }
37 
38         qsort( node+1, inn, sizeof(node[1]), cmp ) ;
39 
40         bool OK = true ; int i ;
41         for( i=1; i<=inn&&0==node[i].isok; i++ ) ;
42         if( i > inn )
43         {
44             printf( "10\n" ) ;
45         }
46         else
47         {
48             forint j=i; j<=inn; j++ ) if0==node[j].isok )
49             {
50                 OK = false ; break ;
51             }
52             if( OK ) 
53             {
54                 printf( "%d\n", node[i].num ) ;
55             }
56             else
57             {
58                 printf( "Inconsistent\n" ) ;
59             }
60         }
61     }
62 
63     return 0 ;
64 }

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理