标签:des style blog color java os strong io
Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 1734 Accepted Submission(s):
506
1 #include<iostream> 2 #include<string> 3 #include<cstdio> 4 #include<vector> 5 #include<queue> 6 #include<stack> 7 #include<algorithm> 8 #include<cstring> 9 #include<stdlib.h> 10 #include<string> 11 #include<cmath> 12 #include<map> 13 using namespace std; 14 #define pb push_back 15 #define mmax 100000 16 int p[21000],First[21000],cx_love[21000][2],now[21000],ans[21000]; 17 int n,m,t; 18 void update(int pos,int num){ 19 while(pos<=20000){ 20 p[pos]+=num; 21 pos+=pos&(-pos); 22 } 23 } 24 int getnum(int pos){ 25 int sum=0; 26 while(pos>=1){ 27 sum+=p[pos]; 28 pos-=pos&(-pos); 29 } 30 return sum; 31 } 32 int main(){ 33 #ifndef ONLINE_JUDGE 34 freopen("input.txt","r" ,stdin); 35 #endif // ONLINE_JUDGE 36 int cas,so=0,cnt;cin>>cas; 37 while(cas--){ 38 memset(p,0,sizeof(p)); 39 for(int i=1;i<=n;i++) now[i]=1; 40 memset(ans,0,sizeof(ans)); 41 cin>>n>>m>>t; 42 char love[10]; 43 int a,b; 44 cnt=0; 45 printf("Case %d:\n",++so); 46 for(int j=1;j<=m;j++){ 47 scanf("%s",love); 48 if(love[0]==‘A‘){ 49 scanf("%d%d",&a,&b); 50 cnt++; 51 cx_love[cnt][0]=a,cx_love[cnt][1]=b; 52 update(a,1); 53 update(b+1,-1); 54 } 55 else{ 56 scanf("%d",&a); 57 int sum=getnum(a); 58 while(now[a]<=cnt){ 59 if(cx_love[now[a]][0]<=a&&a<=cx_love[now[a]][1]){ 60 now[a]+=t; 61 ans[a]++; 62 } 63 else now[a]++; 64 } 65 //ans[a] 记录的是a抵挡攻击的次数 66 //now[a] 记录的是a最后抵挡攻击的时间 67 printf("%d\n",sum-ans[a]); 68 } 69 } 70 } 71 }
hdu 4031 Attack,布布扣,bubuko.com
标签:des style blog color java os strong io
原文地址:http://www.cnblogs.com/ainixu1314/p/3889908.html