- 乒乓球
- 2017-07-09 14:45:58 @
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int tot=1,top=1;
int num1[20005],nun1[20005],nun2[20005],num2[20005];
inline void check(){
if((num1[tot]==11&&nun1[tot]<10)||((num1[tot]>=10&&nun1[tot]>=10)&&(num1[tot]-nun1[tot]>=2))){
tot++;
}
if((nun1[tot]==11&&num1[tot]<10)||((nun1[tot]>=10&&num1[tot]>=10)&&(nun1[tot]-num1[tot]>=2))){
tot++;
}
if((nun2[top]==21&&num2[top]<20)||((nun1[top]>=20&&num1[top]>=20)&&(nun1[top]-num1[top]>=2))){
top++;
}
if((num2[top]==21&&nun2[top]<20)||((num1[top]>=20&&nun1[top]>=20)&&(num1[top]-nun1[top]>=2))){
top++;
}
}
inline void read()
{
char c;
cin>>c;
while(c!='E'){
if(c=='W')num1[tot]++,num2[top]++,check();
if(c=='L')nun1[tot]++,nun2[top]++,check();
if(c=='\n'){
cin>>c;
continue;
}
cin>>c;
};
}
inline void out()
{
for(int i=1;i<=tot;i++)
{
cout<<num1[i]<<":"<<nun1[i]<<endl;
}
cout<<endl;
for(int i=1;i<=top;i++)
{
cout<<num2[i]<<":"<<nun2[i]<<endl;
}
}
int main()
{
memset(num1,0,sizeof(num1));
memset(num2,0,sizeof(num2));
memset(nun1,0,sizeof(nun1));
memset(nun2,0,sizeof(nun2));
read();
out();
return 0;
}
4 条评论
-
liyuu123 LV 7 @ 2017-07-14 15:16:42
@于氏春秋C++ 谢谢!
-
2017-07-09 22:25:02@
@liyuu123 同学,把你的几个1改为了2,又加了几个绝对值,终于AC了。挺有趣的思路,不过似乎能用更为简便的办法。
-
2017-07-09 22:22:54@
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int tot=1,top=1;
int num1[20005],nun1[20005],nun2[20005],num2[20005];
inline void check(){
if((num1[tot]==11&&nun1[tot]<10)||((num1[tot]>=10&&nun1[tot]>=10)&&(abs(num1[tot]-nun1[tot])>=2))){
tot++;
}
if((nun1[tot]==11&&num1[tot]<10)||((nun1[tot]>=10&&num1[tot]>=10)&&(abs(nun1[tot]-num1[tot])>=2))){
tot++;
}
if((nun2[top]==21&&num2[top]<20)||((nun2[top]>=20&&num2[top]>=20)&&(abs(nun2[top]-num2[top])>=2))){
top++;
}
if((num2[top]==21&&nun2[top]<20)||((num2[top]>=20&&nun2[top]>=20)&&(abs(num2[top]-nun2[top])>=2))){
top++;
}
}
inline void read()
{
char c;
cin>>c;
while(c!='E'){
if(c=='W')num1[tot]++,num2[top]++,check();
if(c=='L')nun1[tot]++,nun2[top]++,check();
if(c=='\n'){
cin>>c;
continue;
}
cin>>c;
};
}
inline void out()
{
for(int i=1;i<=tot;i++)
{
cout<<num1[i]<<":"<<nun1[i]<<endl;
}
cout<<endl;
for(int i=1;i<=top;i++)
{
cout<<num2[i]<<":"<<nun2[i]<<endl;
}
}
int main()
{
memset(num1,0,sizeof(num1));
memset(num2,0,sizeof(num2));
memset(nun1,0,sizeof(nun1));
memset(nun2,0,sizeof(nun2));
read();
out();
return 0;
} -
2017-07-09 14:46:25@
希望哪位大佬纠一下错谢谢
- 1