本蒟蒻爆零球爆零了,全TLE(

P1166 打保龄球

布吉岛。 我一中午结果51。 ```cpp #include<bits/stdc++.h> using namespace std; int a[1500][5]; int q[5000],top=0; char b; int n; int main(){ b=0;n=1; memset(a,0,sizeof(a)); while(b!='\n'&&n<=12){ b=getchar(); if(b=='\n')break; else if(b==' ')continue; else if(b=='/'&&a[n][0]==0){a[n][0]=10,a[n][1]=0;top++;q[top]=10;a[n][2]=top;n++;} else { if(b=='/'){a[n][0]=10;a[n][1]=1;top++;q[top]=10-q[top-1];a[n][2]=top;n++;} else { if(a[n][0]!=0){n++; a[n-1][0]+=b-'0',a[n-1][1]=2;top++;a[n-1][2]=top;q[top]=b-'0';} else {a[n][0]+=b-'0';a[n][1]=2;top++;q[top]=b-'0';} } } } /* for(int i=1;i<=10;i++){ cout<<a[i][0]<<" "<<a[i][1]<<" "<<a[i][2]<<endl; } */ int sum=0; for(int i=1;i<=10&&i<n;i++){ if(a[i][1]==0)a[i][0]+=q[a[i][2]+1]+q[a[i][2]+2]; else if(a[i][1]==1)a[i][0]+=q[a[i][2]+1]; if(i+2<n)cout<<a[i][0]<<" "; else if(a[i][1]==2)cout<<a[i][0]<<" "; }cout<<endl; for(int i=1;i<=10&&i<n;i++){ sum+=a[i][0]; cout<<sum<<" "; }cout<<endl; } ```
by 天南星魔芋 @ 2020-10-28 13:46:14


这题好奇怪啊! 1/ 2/ 3/ 45 45 这组样例。 最后面的 45 明显不是附加的, 而且可以确定这轮得分。 但正解就输出 4 轮。 正解 1/ 2/ 3/ 45 45 12 13 14 9 12 25 39 48 本蒟蒻的 1/ 2/ 3/ 45 45 12 13 14 9 9 12 25 39 48 57
by 天南星魔芋 @ 2020-10-28 14:08:30


@[洛璟☭](/user/198719) 我终于过了!!!!! ~~总结出一个结论:对于不带脑子的题面要不带脑子做~~ ~~(因为我是不带脑子做出来的,即瞎搞~~ 代码: ```cpp #include<bits/stdc++.h> using namespace std; int a[1500][5]; int q[5000],top=0; int zan[100],ztop=0; char b[300]; int bb,bbb; int n; int main(){ n=1;bb=0; memset(a,-1,sizeof(a)); memset(q,-1,sizeof(q)); memset(b,0,sizeof(b)); gets(b); bbb=strlen(b); while(b[bb]!='\n'&&n<=12&&bb<bbb){ if(b[bb]=='\n'||b[bb]=='\r')break; else if(b[bb]==' '){bb++;continue;} else if(b[bb]=='/'&&a[n][0]==-1){ a[n][0]=10; a[n][1]=0; top++; q[top]=10; a[n][2]=top; n++; } else { if(b[bb]=='/'){ a[n][0]=10; a[n][1]=1; top++; q[top]=10-q[top-1]; a[n][2]=top; n++; } else if(b[bb]>='0'&&b[bb]<='9'){ if(a[n][0]>=0){ a[n][0]+=b[bb]-'0'; a[n][1]=2; top++; a[n][2]=top; q[top]=b[bb]-'0'; n++; } else { a[n][0]=b[bb]-'0'; a[n][1]=2; top++; q[top]=b[bb]-'0'; } } }bb++; } int sum=0; for(int i=1;i<=10&&i<n;i++){ if(a[i][1]==0){ if(q[a[i][2]+1]==-1||q[a[i][2]+2]==-1){n=i;break;} a[i][0]+=q[a[i][2]+1]+q[a[i][2]+2]; } else if(a[i][1]==1){ if(q[a[i][2]+1]==-1){ n=i;break; } a[i][0]+=q[a[i][2]+1]; } cout<<a[i][0]<<" "; sum+=a[i][0]; zan[i]=sum; }cout<<endl; for(int i=1;i<=10&&i<n;i++){ cout<<zan[i]<<" "; }cout<<endl; } ```
by 天南星魔芋 @ 2020-10-28 14:59:28


```cpp #include<bits/stdc++.h> using namespace std; string s; int a[40],sa,sum[40],t=1,k=1; int main() { getline(cin,s); for(int i=0;i<s.length();i++) if(s[i]=='/'&&s[i-1]==' ')a[t]=10,t++; else if(s[i]=='/'&&s[i-1]!=' ')a[t]=10-a[t-1],t++; else if(s[i]<='9'&&s[i]>='0')a[t]=s[i]-'0',t++; t--; if(a[t]+a[t-1]==10)t-=2; else if(a[t]==10&&a[t-1]==10)t-=2; else if(a[t]==10)t-=1; for(int i=1;i<=t;i++) { if(a[i]==10)sa=a[i]+a[i+1]+a[i+2]; else if(a[i]+a[i+1]==10)sa=10+a[i+2],i++; else sa=a[i]+a[i+1],i++; printf("%d ",sa); sum[k]=sum[k-1]+sa,k++; } printf("\n"); for(int i=1;i<=k-1;i++)printf("%d ",sum[i]); return 0; }
by Real_Luka_Modric @ 2022-09-11 20:23:05


|