HDU 4557 非诚勿扰
2013-11-10 17:58
204 查看
水题,我直接暴力查询的,稍微有点优化就好了。
View Code
#include<stdio.h> #include<iostream> using namespace std; #include<math.h> #include<algorithm> #include<string.h> #include<stdlib.h> #include<vector> #include<set> #include<map> #include<stack> #include<string> #include<queue> #define repA(p,q,i) for( int (i)=(p); (i)!=(q); ++(i) ) #define repAE(p,q,i) for( int (i)=(p); (i)<=(q); ++(i) ) #define repD(p,q,i) for( int (i)=(p); (i)!=(q); --(i) ) #define repDE(p,q,i) for( int (i)=(p); (i)>=(q); --(i) ) #define range 1010 char ope[10]; char name[range][20]; int ab[25][range]; bool confirm[range]; int total; int query(int abl); int main() { int test; scanf("%d",&test); int n, abl, ID; repAE(1,test,round) { printf("Case #%d:\n",round); scanf("%d",&n); memset(confirm, 0 ,sizeof(confirm) ); repA(0,25,i) ab[i][0]=1; ID=total=0; while(n--) { scanf("%s",ope); if( strcmp(ope, "Add") == 0 ) { scanf("%s",name[ID]); scanf("%d",&abl); ab[ abl ][ ab[abl][0]++ ] = ID; ++total; ++ID; printf("%d\n",total); } else { scanf("%d",&abl); int here = query(abl); if(here == -1) printf("WAIT...\n"); else printf("%s\n",name[here]); } } } return 0; } int query(int abl) { if(total == 0) return -1; if(abl > 20 ) return -1; repAE(abl,20,i) { repA(1, ab[ i ][ 0 ], j) { if( !confirm[ ab[i][j] ] ) { confirm[ab[i][j] ] = true; --total; return ab[i][j] ; } } } return -1; }
View Code
相关文章推荐
- hdu 4557 非诚勿扰 vector的应用 原来vector 可以删除指定位置元素 不过消耗大
- 2013金山西山居创意游戏程序挑战赛——复赛(1) HDU 4557 非诚勿扰 HDU 4558 剑侠情缘 HDU 4559 涂色游戏 HDU 4560 我是歌手
- HDU-4557 非诚勿扰
- hdu 4557 非诚勿扰 vector的应用 原来vector 可以删除指定位置元素 不过消耗大
- hdu 4557 非诚勿扰
- 人才能力hdu 4557 非诚勿扰(非暴力,平衡树treap)
- HDU 4557 非诚勿扰 (简单模拟)
- 2013 hdu 西山居复赛(1) HDU 4557 非诚勿扰 HDU 4558 剑侠情缘 HDU 4559 涂色游戏 HDU 4560
- HDU 4557 非诚勿扰 队列、(记一次失败的SBT尝试)
- hdu 4557 非诚勿扰(非暴力,平衡树treap)
- 非诚勿扰 - HDU 4557 - Treap入门
- hdu 4557 非诚勿扰(平衡树方法)
- hdu 4557——非诚勿扰
- HDU 4557-非诚勿扰-字符串
- hdu 4557 非诚勿扰
- hdu 4557 非诚勿扰
- hdu 4557 非诚勿扰 (Java实现)
- hdu 4557 非诚勿扰
- HDU-4557 非诚勿扰
- hdu 4557 暴力