Posted on 2008-12-15 15:48
Hero 阅读(139)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 // 1220 C++ Accepted 0.406 737 KB URAL
2
3 //超级牛的卡内存题目
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8
9 int val[100010] ;
10 short num[100010] ;
11
12 int last[1024] ;
13
14 int inn ;
15 int ina, inb ;
16 char str[10] ;
17 int cnt ;
18
19 int main()
20 {
21 while( scanf( "%d", &inn ) != EOF )
22 {
23 cnt = 0 ;
24
25 for( int i=1; i<=inn; i++ )
26 {
27 scanf( "%s", str ) ;
28 if( 'U' == str[1] )
29 {
30 scanf( "%d %d", &ina, &inb ) ;
31 //node[++cnt].num = ina ; node[cnt].val = inb ;
32 val[i] = inb ; num[i] = ina ;
33 last[ina] = i ;
34 }
35 else
36 {
37 scanf( "%d", &ina ) ; num[i] = 0 ;
38 printf( "%d\n", val[last[ina]] ) ;
39 //node[last[ina]].num = 0 ; last[ina]-- ;
40 num[last[ina]] = 0 ;
41 while( num[last[ina]] != ina && last[ina]) last[ina]-- ;
42 }
43 }
44
45 }
46 return 0 ;
47 }