379 条题解
-
0lyc123456 LV 6 @ 2016-03-09 16:12:49
#include<iostream>
using namespace std;
long long t,i;
char s[1000000];
bool ok(int x,int y,int k)
{
if(x-y>=2 && x>=k)return 1;
if(y-x>=2 && y>=k)return 1;
return 0;
}void write(int k)
{
int i,x=0,y=0;
for(i=0;i<t;i++)
{
if(s[i]=='W')x++;
else y++ ;if(ok(x,y,k))
{
cout<<x<<':'<<y<<endl;
x=0,y=0;
}
}
cout<<x<<":"<<y;
}int main()
{
while(cin>>s[t],s[t]!='E')
if(s[t]=='W' || s[t]=='L') t++;write(11);
cout<<endl;
write(21);return 0;
} -
02015-10-07 22:35:48@
记录信息
评测状态 Accepted
题目 P1217 乒乓球
递交时间 2015-10-07 22:35:31
代码语言 C++
评测机 VijosEx
消耗时间 142 ms
消耗内存 8360 KiB
评测时间 2015-10-07 22:35:32
评测结果
编译成功foo.cpp: In function 'int main()':
foo.cpp:12:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
while(c=getchar())
^
foo.cpp:29:11: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if(A1>10&&A1-B1>=2||B1>10&&B1-A1>=2){
^
foo.cpp:34:11: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if(A2>20&&A2-B2>=2||B2>20&&B2-A2>=2){
^
测试数据 #0: Accepted, time = 0 ms, mem = 8360 KiB, score = 10
测试数据 #1: Accepted, time = 15 ms, mem = 8352 KiB, score = 10
测试数据 #2: Accepted, time = 15 ms, mem = 8352 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 8352 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 8356 KiB, score = 10
测试数据 #5: Accepted, time = 46 ms, mem = 8352 KiB, score = 10
测试数据 #6: Accepted, time = 31 ms, mem = 8356 KiB, score = 10
测试数据 #7: Accepted, time = 2 ms, mem = 8356 KiB, score = 10
测试数据 #8: Accepted, time = 1 ms, mem = 8352 KiB, score = 10
测试数据 #9: Accepted, time = 2 ms, mem = 8352 KiB, score = 10
Accepted, time = 142 ms, mem = 8360 KiB, score = 100
代码
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int qu[2000010];
int cnt;
char c;
int main()
{
int A1=0,B1=0,A2=0,B2=0;
while(c=getchar())
{
if(c=='\n'||c==' ')continue;
if(c=='E'){
printf("%d:%d\n",A1,B1);
qu[cnt]=A2,qu[cnt+1]=B2;
cnt+=2;
break;
}
if(c=='W'){
A1++;
A2++;
}
else {
B1++;
B2++;
}
if(A1>10&&A1-B1>=2||B1>10&&B1-A1>=2){
printf("%d:%d\n",A1,B1);
A1=0;
B1=0;
}
if(A2>20&&A2-B2>=2||B2>20&&B2-A2>=2){
qu[cnt]=A2;
qu[cnt+1]=B2;
cnt+=2;
A2=B2=0;
}
}
printf("\n");
for(int i=0;i<cnt;i+=2)
printf("%d:%d\n",qu[i],qu[i+1]);
} -
02015-08-17 10:43:11@
C语言
#include <stdio.h>
#include <string.h>
int main()
{
int i=0,m=0,n=0,j;
char a[100001];//范围太大不行,太小也不行
do
{
i++;
scanf("%c",&a[i]);
}while(a[i] != 'E');
for(i=1;a[i] != 'E';i++)
{
if(a[i]=='W')
m++;
else if(a[i] == 'L')
n++;
else if(a[i] == '\n')
continue;
else if(a[i] == 'E')
break;
if((m>=11||n>=11)&&(m-n>=2||n-m>=2))//如果胜利,就直接输出,说明这一局已经结束了
{
printf("%d:%d\n", m, n);
m=0;
n=0;
}//用括号括起来 不然不管输出与否 都会清零
}
printf("%d:%d\n", m, n);//不管胜利与否 都输出 清零
m=0;
n=0;
for(i=1;a[i] != 'E';i++)
{
if(a[i]=='W')
m++;
else if(a[i] == 'L')
n++;
else if(a[i] == ' ')
continue;
else if(a[i] == 'E')
break;
if((m>=21||n>=21)&&(m-n>=2||n-m>=2))
{
printf("%d:%d\n", m, n);
m=0;
n=0;
}
}
printf("%d:%d\n", m, n);
return 0;
} -
02015-05-11 16:44:21@
#include <iostream>
#include <cstdlib>using namespace std;
int a[10000] = {}, b[10000] = {};
int main(){
char c;
int W = 0, L = 0, W2 = 0, L2 = 0;
int js = 0;
while(cin >> c){
if(c == 'E'){
break;
}
if(c == 'W'){
++W,++W2;
}
if(c == 'L'){
++L,++L2;
}
if((W >= 11 || L >= 11) && abs(W - L) > 1){
cout << W << ":" << L << endl;
W = L = 0;
}
if((W2 >= 21 || L2 >= 21) && abs(W2 - L2) > 1){
a[js] = W2, b[js++] = L2;
W2 = L2 = 0;
}
}
cout << W << ":" << L << endl << endl;
for(int i = 0; i < js; ++i){
cout << a[i] << ':' << b[i] << endl;
}
cout << W2 << ':' << L2;
} -
02014-12-13 22:40:29@
请千万注意:如果新开一盘后立刻结束,也得输出0:0!
试试如下数据:WWWWWLLWLLLLWLWLWLWLWWE
正确输出应为:
12:10
0:012:10
第一次交的时候还特别加了判断,不输出0:0,以致WA了2个点。实在是想得太多反倒不好
-
02014-11-30 19:15:34@
#include<cmath>
#include<iostream>
using namespace std;
main()
{
char c;
int a[10000][2],b=0,d=0,i,l=0,p=0,w=0;
while(1)
{
cin>>c;
if(c=='E')
break;
if(c=='W')
{
w++;
b++;
}
else
if(c=='L')
{
l++;
d++;
}
if((w>=11||l>=11)&&abs(w-l)>=2)
{
cout<<w<<':'<<l<<endl;
w=0;
l=0;
}
if((b>=21||d>=21)&&abs(b-d)>=2)
{
a[++p][0]=b;
a[p][1]=d;
b=0;
d=0;
}
}
cout<<w<<':'<<l<<"\n\n";
for(i=1;i<=p;i++)
cout<<a[i][0]<<':'<<a[i][1]<<endl;
cout<<b<<':'<<d;
} -
02014-11-05 16:50:18@
var
x,y:array[0..10000]of longint;
a,b,t,i:longint;
c:char;
begin
t:=1;
repeat
read(c);
if c='E'then break;
if c='W'then begin inc(a);inc(x[t]);end;
if c='L'then begin inc(b);inc(y[t]);end;
if((a>10)or(b>10))and(abs(a-b)>1)then begin
writeln(a,':',b);
a:=0;
b:=0;
end;
if((x[t]>20)or(y[t]>20))and(abs(x[t]-y[t])>1)then inc(t);
until false;
writeln(a,':',b);
writeln;
for i:=1 to t do writeln(x[i],':',y[i]);
end. -
02014-11-05 16:48:46@
var
ch:char;
s:ansistring;
i,n,fen1,fen2,fen3,fen4:longint;
d:boolean;
begin
read(ch);d:=false;
while ch<>'E' do
begin
s:=s+ch;
read(ch);
d:=true;
end;
if not d then
begin
writeln('0:0');
writeln;
writeln('0:0');
end
else
begin
fen1:=0;fen2:=0;
for i:=1 to length(s) do
begin
if s[i]='W' then inc(fen1) ;
if s[i]='L' then inc(fen2);
if ((fen1>=11) or (fen2>=11)) and(abs(fen1-fen2)>1) then
begin
writeln(fen1,':',fen2);
fen1:=0;fen2:=0;
end;
end;
writeln(fen1,':',fen2);writeln;
for i:=1 to length(s) do
begin
if s[i]='W' then inc(fen3) ;
if s[i]='L' then inc(fen4);
if ((fen3>=21) or (fen4>=21)) and (abs(fen3-fen4)>1) then
begin
writeln(fen3,':',fen4);
fen3:=0;fen4:=0;
end;
end;
if fen3+fen4<>0 then writeln(fen3,':',fen4);
end;
end. -
02014-11-05 16:48:00@
var
ch:char;
s:ansistring;
i,n,fen1,fen2,fen3,fen4:longint;
d:boolean;
begin
read(ch);d:=false;
while ch<>'E' do
begin
s:=s+ch;
read(ch);
d:=true;
end;
if not d then
begin
writeln('0:0');
writeln;
writeln('0:0');
end
else
begin
fen1:=0;fen2:=0;
for i:=1 to length(s) do
begin
if s[i]='W' then inc(fen1) ;
if s[i]='L' then inc(fen2);
if ((fen1>=11) or (fen2>=11)) and(abs(fen1-fen2)>1) then
begin
writeln(fen1,':',fen2);
fen1:=0;fen2:=0;
end;
end;
writeln(fen1,':',fen2);writeln;
for i:=1 to length(s) do
begin
if s[i]='W' then inc(fen3) ;
if s[i]='L' then inc(fen4);
if ((fen3>=21) or (fen4>=21)) and (abs(fen3-fen4)>1) then
begin
writeln(fen3,':',fen4);
fen3:=0;fen4:=0;
end;
end;
if fen3+fen4<>0 then writeln(fen3,':',fen4);
end;
end. -
02014-10-10 19:16:19@
零比零都要输出,有点坑洼
var
ch:char;
s:ansistring;
i,n,fen1,fen2,fen3,fen4:longint;
d:boolean;
begin
read(ch);d:=false;
while ch<>'E' do
begin
s:=s+ch;
read(ch);
d:=true;
end;
if not d then
begin
writeln('0:0');
writeln;
writeln('0:0');
end
else
begin
fen1:=0;fen2:=0;
for i:=1 to length(s) do
begin
if s[i]='W' then inc(fen1) ;
if s[i]='L' then inc(fen2);
if ((fen1>=11) or (fen2>=11)) and(abs(fen1-fen2)>1) then
begin
writeln(fen1,':',fen2);
fen1:=0;fen2:=0;
end;
end;
writeln(fen1,':',fen2);writeln;
for i:=1 to length(s) do
begin
if s[i]='W' then inc(fen3) ;
if s[i]='L' then inc(fen4);
if ((fen3>=21) or (fen4>=21)) and (abs(fen3-fen4)>1) then
begin
writeln(fen3,':',fen4);
fen3:=0;fen4:=0;
end;
end;
if fen3+fen4<>0 then writeln(fen3,':',fen4);
end;
end. -
02014-10-08 22:20:33@
相信我
-
02014-10-08 22:20:16@
var
k:char;
num,w,l,a,b,n:longint;
all:array[1..100000]of char;
procedure ready;
var
i:longint;
begin
n:=1;
read(all[n]);
while all[n]<>'E' do
begin
n:=n+1;
read(all[n]);
end;
for i:=1 to 100000 do
if all[i]='E' then num:=i;
end;
procedure work11;
var
i:longint;
begin
for i:=1 to num do
begin
if all[i]='W' then w:=w+1;
if all[i]='L' then l:=l+1;
if ( ((w=a)or(l=a)) and ((w-l<-1)OR(w-l>1)) ) or (i=num) then
begin
write(w ,':',l );
writeln;
w:=0;
l:=0;
a:=11;
end
else if ((w=a)or(l=a))and((w-l=-1)or(w-l=1)or(w-l=0)) then
a:=a+1;
end;
end;
procedure work21;
var
i:longint;
begin
for i:=1 to num do
begin
if all[i]='W' then w:=w+1;
if all[i]='L' then l:=l+1;
if (((w=b)or(l=b))and((w-l<-1)OR(w-l>1)))or(i=num) then
begin
write(w ,':',l );
writeln;
w:=0;
l:=0;
b:=21;
end
else if ((w=b)or(l=b))and((w-l=-1)or(w-l=1)or(w-l=0)) then
b:=b+1;
end;
end;
begin
ready;
a:=11; b:=21;
w:=0; l:=0;
work11;
writeln;
work21;
end. -
02014-10-04 21:14:25@
值此留念,希望帮上大家!
program pingpang;
var
c:char;
a,b:array[1..100000] of longint;
i,k,l,m,n,p,o:longint;
begin
o:=0;
repeat
inc(o);
read(c);
if c='W' then
begin
inc(k);
inc(m);
end;
if c='L' then
begin
inc(n);
inc(l);
end;
if c='E' then
begin
if o=1 then
begin
writeln('0:0');
writeln;
writeln('0:0');
halt;
end;
if (m<>0) or (n<>0) then writeln(m,':',n)
else writeln('0:0');
inc(p);
a[p]:=k;
b[p]:=l;
break;
end;
if ((m>=11) or (n>=11)) and (abs(m-n)>1) then
begin
writeln(m,':',n);
m:=0;
n:=0;
end;
if ((k>=21)or(l>=21))and(abs(k-l)>1) then
begin
inc(p);
a[p]:=k;
b[p]:=l;
k:=0;
l:=0
end;
until false;
writeln;
for i:=1 to p-1 do
writeln(a[i],':',b[i]);
if (a[p]<>0) or (b[p]<>0) then writeln(a[p],':',b[p]);
end. -
02014-08-24 13:40:34@
为毛???
测试数据 #0: Accepted, time = 0 ms, mem = 608 KiB, score = 10测试数据 #1: Accepted, time = 0 ms, mem = 608 KiB, score = 10
测试数据 #2: Accepted, time = 15 ms, mem = 608 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 604 KiB, score = 10
测试数据 #5: WrongAnswer, time = 3 ms, mem = 608 KiB, score = 0
测试数据 #6: Accepted, time = 15 ms, mem = 604 KiB, score = 10
测试数据 #7: Accepted, time = 7 ms, mem = 604 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 608 KiB, score = 10
-
02014-08-20 09:40:04@
成功AC100题留纪念~
测试数据 #0: Accepted, time = 7 ms, mem = 1072 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 1072 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 1072 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 1076 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 1076 KiB, score = 10
测试数据 #5: Accepted, time = 11 ms, mem = 1076 KiB, score = 10
测试数据 #6: Accepted, time = 11 ms, mem = 1076 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 1072 KiB, score = 10
测试数据 #8: Accepted, time = 15 ms, mem = 1076 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 1076 KiB, score = 10
Accepted, time = 44 ms, mem = 1076 KiB, score = 100
##Code
var a:array[1..100000] of char;
w,w1,l,l1:array[1..10000] of longint;
i,k,k1,n:longint;
begin
n:=1;
read(a[n]);
while a[n]<>'E' do
begin
n:=n+1;
read(a[n]);
end;
k:=1;
for i:=1 to n-1 do
begin
if a[i]='W' then
begin
w[k]:=w[k]+1;
if (w[k]>=11) and (abs(w[k]-l[k])>=2) then k:=k+1;
end;
if a[i]='L' then
begin
l[k]:=l[k]+1;
if (l[k]>=11) and (abs(w[k]-l[k])>=2) then k:=k+1;
end;
end;
k1:=1;
for i:=1 to n-1 do
begin
if a[i]='W' then
begin
w1[k1]:=w1[k1]+1;
if (w1[k1]>=21) and (abs(w1[k1]-l1[k1])>=2) then k1:=k1+1;
end;
if a[i]='L' then
begin
l1[k1]:=l1[k1]+1;
if (l1[k1]>=21) and (abs(w1[k1]-l1[k1])>=2) then k1:=k1+1;
end;
end;
for i:=1 to k do
writeln(w[i],':',l[i]);
writeln;
for i:=1 to k1 do writeln(w1[i],':',l1[i]);
end. -
02014-08-16 19:56:39@
var
x,y:array[0..10000] of longint;
a,b,t,i:longint;
c:char;
begin
t:=1;
repeat
read(c);
if c='E'then break;
if c='W'then begin inc(a);inc(x[t]);end;
if c='L'then begin inc(b);inc(y[t]);end;
if ((a>10) or (b>10)) and (abs(a-b)>1) then
begin
writeln(a,':',b);
a:=0;
b:=0;
end;
if((x[t]>20) or (y[t]>20)) and (abs(x[t]-y[t])>1) then inc(t);
until false;
writeln(a,':',b);
writeln;
for i:=1 to t do
writeln(x[i],':',y[i]);
end.//By fkc -
02014-08-16 19:46:43@
.
-
02014-03-25 15:11:04@
一、数据量比较大,string不够用,要用ansistring
二、乒乓球规则,分差2分及以上才能算赢
三、如果一局比赛刚刚开始,那么不要忘记输出0:0,比赛时三局两胜制 -
02014-01-17 18:34:53@
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
int main()
{
char a[60000];
int i=0,w11=0,l11=0,w21=0,l21=0;
while((a[i]=getchar())!='E')
{i++;}
for(int j=0 ; j<=i ; j++)
{
if( (w11>=11||l11>=11) && (abs(w11-l11)>=2) ) { cout<<w11<<":"<<l11<<"\n"; w11=0; l11=0; }
if( a[j]=='W') { w11++; }
if( a[j]=='L') { l11++; }
if( (a[j]=='E')&& (w11==0) && (l11==0) ) { cout<<"0:0\n\n"; break;}
if( (a[j]=='E')&& ( w11||l11) ) { cout<<w11<<":"<<l11<<"\n\n"; break; }
}
for(int j=0 ; j<=i ; j++)
{
if( (w21>=21||l21>=21) && (abs(w21-l21)>=2) ) { cout<<w21<<":"<<l21<<"\n"; w21=0; l21=0; }
if( a[j]=='W') { w21++; }
if( a[j]=='L') { l21++; }
if( (a[j]=='E')&& (w21==0) && (l21==0) ) { cout<<"0:0\n"; break;}
if( (a[j]=='E')&& ( w21||l21) ) { cout<<w21<<":"<<l21<<"\n"; break; }
}
system("pause");
return 0;
} -
02013-08-09 21:28:55@
program pingpangqiu;
var
a:array[1..30000] of char;
i,j,k,h11,l11,h21,l21:integer;
b:array[1..2,1..100] of integer;
c:array[1..2,1..100] of integer;
begin
h11:=0;l11:=0;h21:=0;l21:=0; j:=0;k:=0;
repeat
inc(i);
if i mod 20=0 then readln(a[i])
else read(a[i]);
if a[i]='W' then begin inc(h11); inc(h21); end;
if a[i]='L' then begin inc(l11); inc(l21); end;
if ((h11>=11)and(h11-l11>=2)) then begin inc(j);c[1,j]:=h11;c[2,j]:=l11; h11:=0; l11:=0; end;
if ((h11>=11)and(h11-l11>=2)) then begin inc(j);c[1,j]:=h11;c[2,j]:=l11; h11:=0; l11:=0;end;
if ((h21>=21)and(h21-l21>=2)) then begin inc(k);b[1,k]:=h21;b[2,k]:=l21; h21:=0; l21:=0; end;
if ((l21>=21)and(l21-h21>=2)) then begin inc(k);b[1,k]:=h21;b[2,k]:=l21; h21:=0; l21:=0; end;
until a[i]='E';
for i:=1 to j do
writeln(c[1,j],':',c[2,j]);
if (h11<>0) or (l11<>0) then writeln(h11,':',l11);
writeln;
for i:=1 to k do
writeln(b[1,k],':',b[2,k]);
if (h21<>0) or (l21<>0) then writeln(h21,':',l21);
readln;
end.